简体   繁体   English

如何使用 Bash 或 shell 脚本在 xmgrace 中绘制线条

[英]How to plot line in xmgrace using Bash or shell script

我想使用脚本在 xmgrace 中的特定点(例如 2.2)绘制垂直虚线红线

You can either use an external tool such as pygrace or use grace's built-in batch capabilities.您可以使用外部工具(例如pygrace)或使用 grace 的内置批处理功能。 These have been touched upon here on SO before (see, for instance, here or here ).这些之前已经在 SO 上有所涉及(例如,请参阅此处此处)。

The following script plots a datafile ( exp.dat ) as empty circles, another data file ( line.dat ) as a red dotted line and sets the ranges, labels and major ticks of the two axes:以下脚本将数据文件 ( exp.dat ) 绘制为空圆圈,将另一个数据文件 ( line.dat ) line.dat为红色虚线,并设置两个轴的范围、标签和主要刻度:

READ NXY "exp.dat"
READ NXY "line.dat"

WORLD XMIN 0
WORLD XMAX 5
WORLD YMIN 1
WORLD YMAX 5
xaxis label "My x label"
xaxis tick major 1
yaxis label "My y label"
yaxis tick major 1

s0 line type 0
s0 symbol 1
s0 symbol size 1.5

s1 linestyle 2
s1 color 2

To generate a vertical red dotted line that passes through 2.2 the contents of line.dat should be something like要生成通过 2.2 的垂直红色虚线, line.dat的内容应该类似于

2.2 0
2.2 10000

You can generate such a file in a bash script with the following command:您可以使用以下命令在 bash 脚本中生成这样的文件:

echo "2.2 0\n2.2 10000" > line.dat

Save the script as mybatch.xmg and call it like this:将脚本保存为mybatch.xmg并像这样调用它:

xmgrace -batch mybatch.xmg

If you want to directly generate an output you can add this directive:如果要直接生成输出,可以添加以下指令:

PRINT TO "myplot.eps"
DEVICE "EPS" OP "level2"
PRINT

which will save your plot as myplot.eps (add -nosafe when calling xmgrace to get rid of the warnings).这将节省您的情节一样myplot.eps (添加-nosafe打电话时xmgrace摆脱警告)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM