gnuplot - 如何从文本文件中的一系列 grepped 数据在 gnuplot 中制作箭头脚本
问题描述
我的数据文件是:
=============
This is your required output
Range: -42.3732 666.3634eV Yi, Yf > DATA-point FIX: 0.0000 0.0000 0.0000 x LIST 0.0000
DATA-point FIX: 0.5000 0.0000 0.0000 x LIST 0.5000
DATA-point FIX: 0.7500 0.3750 0.2641 x LIST 1.0224
DATA-point FIX: 0.0000 0.0000 0.0000 x LIST 1.9015
DATA-point FIX: 0.3750 0.3750 0.5282 x LIST 2.6500
DATA-point FIX: 0.5000 0.5000 0.3522 x LIST 2.8995
DATA-point FIX: 0.0000 0.0000 0.0000 x LIST 3.6895
DATA-point FIX: 0.5000 0.0000 0.3522 x LIST 4.3010
DATA-point FIX: 0.6250 0.2500 0.4402 x LIST 4.5941
DATA-point FIX: 0.7500 0.2500 0.3522 x LIST 4.7470
DATA-point FIX: 0.5000 0.5000 0.3522 x LIST 5.1005
DATA-point FIX: 0.5000 0.2500 0.5282 x LIST 5.4063
done junk has written below this part
========
我要设置号码
`-42.3732 and 666.3634 as y-axis limit`
然后想从中绘制箭头
Xi, Yi to Xi, Yi nohead
其中 Xi 是一个变量数,取决于数据文件,但我可以使用 grep
grep LIST data.dat | awk '{print $NF}'
和
Yi and Yf are the y-axis limit as mentioned above but changes according to data file so these numbers are not the one that I mention here).
我想在我的 gnu 脚本中从 Xi、Yi 到 Xi、Yf 的每个点上绘制箭头。
我有一些想法,如果我们将上述数据以变量形式存储并且这样做可以做到这一点
set VARIABLE
变量是这样的
VARIABLE=`arrow from Xi,Yi to Xi,Yf nohead ; set`
对于下一部分,我想用一些字母来标记 x 轴上的每个 Xi
X, Y, Z, .....
你能告诉我如何在gnuplot中管理它吗?
解决方案
从您的描述中我仍然不清楚从哪里获得哪些值。
我的理解如下:您有一个(或几个?)文件具有您提供的结构(而第二行的结构>
和之后的数据对我来说看起来很奇怪)。据我了解,awk 命令提取一行中最后一个标记(列)的值。所以,我假设xi
是每行的最后一个值。在第 2 行中,xi
将在第 14 列中,在以下所有行xi
中,将在第 8 列中。
gnuplot(没有 awk)中的过程如下:
- 将文件绘制到虚拟表中。如果行号为 1(即
($0==1)
),则将第 2$2
列和第 3列中的值分别分配$3
给Ymin
和Ymax
。始终将列值 8 分配$8
给Xmax
,因此绘图Xmax
后将包含最后一个值,此处为 5.4063。 - 然后绘制文件
with vectors
(跳过第一行)并将第 14 列用于下一行,将第 8 列用于所有其他行作为xi
值。
在您发表评论后,这可能是您想要的更多。您可以在键入时从 gnuplot 帮助中获取详细信息help <keyword>
,例如help vectors
.
代码:(评论后修改)
### Extract values from file
reset session
FILE = 'tbExtractArrow.dat'
# extract Ymin, Ymax and Xmax
set table $Dummy
plot FILE u ($0==1?(Ymin=$2,Ymax=$3):NaN,Xmax=$8) w table
unset table
print Ymin,Ymax,Xmax
# define formula for column to extract xi
myColumn(n) = n==0 ? 14 : 8
set xrange [0:Xmax]
set yrange[Ymin:Ymax]
set xtics ( "{/Symbol G}" 0.00000, "{/Times-New, F}" 0.27445, "{/Times-New Q}" 0.46775, "{/Times-New, Z}" 0.74220, "{/Symbol G}" 0.93550, "etc." 1.4)
plot FILE skip 1 u (column(myColumn($0))):(Ymin):(0):(Ymax-Ymin) w vectors nohead lw 2 lc rgb "red" notitle
### end of code
结果:
推荐阅读
- python - 玩家在pygame中移动不顺畅
- amazon-web-services - 我无法从 AWS 建议的我的 IP SSH 到我的 Linux EC2 实例。如果传入规则设置为 ::0 它可以工作
- azure-service-fabric - 有关 Azure 门户中“Service Fabric 群集”页面的问题
- ios - React Native iOS:允许在应用程序方向锁定为纵向时旋转 pdf 或其他文件
- python - 在 python (pandas) 中追加函数
- node.js - 错误代码:尝试在 Visual Studio 代码编辑器上运行 Node JS 时出现 800a03f6
- typescript - 在 Typescript 中创建泛型类型
- linux - 如何使用 jq 循环访问数组的所有对象?
- python - 如何在同一台计算机上工作的 2 个 python 脚本之间在 GStreamer 中流式传输音频?
- windows - 平台什么时候不支持ssl?(QSslSocket::supportsSsl() 返回 false)