本文介绍了使用XMGRACE工具绘制数据的Bash脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个bash脚本,该脚本生成包含数据的文件并将其保存到目录中.我希望我的脚本也使用xmgrace绘制这些文件.

I have written a bash script that generates files containing data and saves them to a directory. I would like my script to also plot these files using xmgrace.

最初,我只需要一个命令行或一系列命令行即可创建一个xmgrace文件,保存该文件,选择y和x轴的比例,将y轴设置为对数,将x和y轴标记为给图加标题.

Initially I just need a command line or series of command lines that will create an xmgrace file, save it, choose the scales of the y and x axis, set the y axis to be logarithmic, label the x and y axis and title the graph.

我已经尝试过以该行开头

I have tried the line to start with

    xmgrace filename xaxis label "Label 1" yaxis label "Label 2" PRINT TO "filename.eps" DEVICE "EPS" OP "level2"

这将绘制数据,但不会在其上粘贴或保存标签,并且终端会返回

This plots the data but does not put the labels on it or save it and the terminal returns

    Can't stat file xaxis
    Can't stat file label
    Can't stat file Label 1
    ...
    ...

在此命令行中还可以放置一个标志,以便xmgrace实际不打开文件,它只是创建并保存文件.在Bash脚本中使用它会更好.

Is there also a flag I can put in this command line so that xmgrace does not actually open the file, it just creates it and saves it. This would be much better when I use it in the Bash Script.

非常感谢您

p.s.我仅使用xmgrace,因为它是我最熟悉的手动使用的绘图工具.如果有任何建议为该任务提供更合适的工具,我将表示欢迎.

p.s. I am only using xmgrace because it it the plotting tool I am most familiar with to use manually. I would welcome any suggestion of more appropriate tools for this task.

推荐答案

是的,可以在不使用GUI的情况下调用xmgrace/Grace(使用gracebat),但是您使用的命令必须首先在脚本文件中

Yes, it is possible to call xmgrace/Grace without the GUI (using gracebat), but the commands you have used must first be inside a script file.

"script.bat"文件的内容:

Contents of file "script.bat":

xaxis label "Label 1"
yaxis label "Label 2"
DEVICE "EPS" OP "level2"
PRINT TO "plot.eps"
PRINT

现在,对于两列数据文件"data.dat",您将调用名为gracebat的姊妹可执行文件,该文件与xmgrace相同,但以批处理模式运行(没有GUI):

Now, for a two-column data file "data.dat" you call a sister executable named gracebat which is the same as xmgrace but operates in batch mode (without the GUI):

gracebat -nosafe data.dat -batch script.bat

其中

-batch <script>告诉宽限期寻找并执行脚本文件(告诉宽限期以批处理模式运行!).

-batch <script> tells grace to look for and execute a script file (does not tell grace to run in batch mode!).

-nosafe覆盖默认的安全模式,该模式应停止文件修改.没有它,您将看到一条错误消息(尽管在我的情况下,情节文件仍在写入中).

-nosafe overrides the default safe mode, which is supposed to stop file modifications. Without it you would see an error message (although in my case the plot file was still written).

这篇关于使用XMGRACE工具绘制数据的Bash脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 16:04