Gnuplot 脚本,for 循环内或添加到现有绘图
我想在 gnuplot 中以设定的间隔绘制一系列垂直线。
有关剧情的一些信息。
该图主要是 .dat 文件中的一些数据。 gnuplot 脚本由 bash 脚本调用,该脚本使用 sed 更改 gnu 绘图脚本。这是旧 bash 脚本的一个片段(我确信很难看)。
sed -i 's/C = CONCEHOLD/C = '${$CO}'/g' $GNUPLOTROOT/plotviscosity.plt
gnuplot $GNUPLOTROOT/plotviscosity.plt
mv my-plot.ps $VISCPLOTNAME
sed -i 's/C = '${$CO}'/C = CONCEHOLD/g' $GNUPLOTROOT/plotviscosity.plt
与 . plt 文件看起来像这样。
set title "Viscosity vs Time, C = CONCEHOLD, beta = RATHOLD, zeta = ZETAHOLD"
set xlabel "Time"
set ylabel "Viscosity"
plot "viscout.dat" using 3:2 title 'Viscosity'
# Saving to my-plot.ps
load save.plt
#
我想在该图中以设定的重复间隔添加一系列垂直线。我找到了如何通过 http://t16web.lanl.gov/Kawano/gnuplot/parametric-e.html
set parametric
const=3
set trange [1:4]
set xrange [0:5]
set yrange [0:5]
plot const,t
我想要
const=repititionperiod*i
其中 i 是属于 (1,calculateduppedlimit] 的整数。
我可以通过输入 repititionperiod再次使用 sed 并以类似的徒劳的calculateduppedlimit,但需要在 gnuplot 或单独的 gnuplot 脚本中进行某种 for 循环,该循环在我的 bash 脚本中的 for 循环中向已创建的绘图添加一条垂直线,
我找不到任何相关信息 。在 gnu 绘图中循环或添加到以前创建的绘图中,
非常感谢收到的任何建议。
I would like to plot a series of vertical lines in gnuplot at a set interval.
Some information about the plot.
The plot is mainly some data from a .dat file. The gnuplot script is called by a bash scripts which alters the gnu plot script using sed. This is a snipit of the an old bash script (ugly I'm sure).
sed -i 's/C = CONCEHOLD/C = '${$CO}'/g' $GNUPLOTROOT/plotviscosity.plt
gnuplot $GNUPLOTROOT/plotviscosity.plt
mv my-plot.ps $VISCPLOTNAME
sed -i 's/C = '${$CO}'/C = CONCEHOLD/g' $GNUPLOTROOT/plotviscosity.plt
with the . plt file looking like this.
set title "Viscosity vs Time, C = CONCEHOLD, beta = RATHOLD, zeta = ZETAHOLD"
set xlabel "Time"
set ylabel "Viscosity"
plot "viscout.dat" using 3:2 title 'Viscosity'
# Saving to my-plot.ps
load save.plt
#
I would like to add to this plot a series of vertical lines at a set repeating interval. I have found how to plot vertical lines via http://t16web.lanl.gov/Kawano/gnuplot/parametric-e.html
set parametric
const=3
set trange [1:4]
set xrange [0:5]
set yrange [0:5]
plot const,t
I would like to have
const=repititionperiod*i
where i is an integer belonging to (1,calculateduppedlimit].
I could input repititionperiod via sed again and in a similar vain calculateduppedlimit but need some sort of for loop either within gnuplot or a separate gnuplot script that adds a vertical line to the already created plot within a for loop in my bash script.
I can't find any information on loops within gnu plot or adding to a previously created plot.
Any advice gratefully received.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑: Gnuplot 现在实际上支持 for 循环,您可以阅读它此处
据我了解,gnuplot 没有 for 循环,尽管您可以按如下方式生成其中一种:
制作文件 包含“loop.gp”
然后在 gnuplot 终端中
,或者编写脚本,这将为您提供一个简单的循环。
(此示例取自 http://t16web.lanl.gov/Kawano/gnuplot/index-e.html)
对于您的特定答案,您可以尝试添加箭头而不是参数线,
例如。
会做很多同样的事情。
在这种情况下,您可以使用loop.gp,
并且可以使用以下命令运行循环
。replot 会绘制箭头。
如果您“只是”想要线条而不需要其他东西 - 那么您将需要提供一个图表来实际绘制(一组箭头不算)。然后可以使用您给出的示例来绘制第一条垂直线。
希望这有帮助。
汤姆
EDIT: Gnuplot does now in fact now support a for loop, you can read about it here
As I understand gnuplot doesn't have a for loop, although you can generate one of sorts as follows:
Make a file "loop.gp" containing
then in a gnuplot terminal, or script write,
This will give you a simple loop.
(this example is taken from the misc. section of http://t16web.lanl.gov/Kawano/gnuplot/index-e.html)
For your particular answer you might try adding arrows rather than paremetric lines,
eg.
will do much the same thing.
In this case you loop.gp could be
and you would run you loop with
The replot plots the arrows.
If you "just" want the lines and nothing else - then you will need to feed a graph to actually plot (a set of arrows doesn't count). The example you gave could then be used to plot the first vertical line.
hope this helps.
Tom