以编程方式修改 gnuplot 脚本内的变量
我有一个由我的程序生成的值的配对 t 文件,教授为我们提供了一个基本的 gnuplot 脚本供我们使用。然而,标题、输出文件名和输入数据文件都是硬编码在脚本中的。
有没有办法修改绘图文件中的变量?
例如,当前标题是通过
set title "Voting"
完成的,绘图命令是通过
plot 'data-confidence' using 14:3:9:12 notitle with errorbars, \
'data-confidence' using 14:3 notitle with points 2
Is it possible to do things like
gnuplotpairedt.g votevoting.data
执行的并在 .data 文件上执行脚本?
I have a paired t file of values generated from my program, and the professor has given us a basic gnuplot script to work from. However, the title, output filename and input data file are all hard-coded in the script.
Is there any way to modify the variables inside the plot file?
for example, the current title is done via
set title "Voting"
and the plot command is executed via
plot 'data-confidence' using 14:3:9:12 notitle with errorbars, \
'data-confidence' using 14:3 notitle with points 2
Is it possible to do something like
gnuplot pairedt.g voting voting.data
and have the script execute on the .data file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 gnuplot 脚本转换为 shell 脚本,通过变量替换填充所需的名称。一个很好的方法是使用此处文档。
一个最小的示例:
这使用脚本的第一个参数来确定输出文件名和数据文件的名称。
Convert the gnuplot script into a shell script that fills in the needed names by variable substitution. A nice way to do this is by using a here document.
A minimal example:
This uses the first argument to the script to determine both the output file name and the name of the data file.
我有点不清楚你到底想要什么,但我认为你有两种可能的方法来解决这个“问题”:
编辑 gnuplot 脚本,以便支持你的数据文件的外观。或者更好的是,编写您自己的脚本来绘制数据。
编辑生成输出文件的程序,以便
data-confidence
,14:3:9:12
引用(请参阅 此处查看文档))It is a little unclear to me what you are exactly after but I think there are two possible ways for you to solve this "issue":
Edit the gnuplot script so that is supports the way your data file looks. Or even better, write your own script that plots your data.
Edit your program that generates the output file so that
data-confidence
,14:3:9:12
(see here for the documentation))