Gnuplot脚本,用于在内部绘图中循环或添加到现有绘图中 [英] Gnuplot script, for loop within or adding to existing plot

查看:111
本文介绍了Gnuplot脚本,用于在内部绘图中循环或添加到现有绘图中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以一定的间隔在gnuplot中绘制一系列垂直线.

I would like to plot a series of vertical lines in gnuplot at a set interval.

有关情节的一些信息.

该图主要是来自.dat文件的一些数据. gnuplot脚本由bash脚本调用,bash脚本使用sed更改gnu plot脚本.这是旧的bash脚本的伪装(我敢肯定,这很丑).

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

与.像这样的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
#

我想在此图上以一定的重复间隔添加一系列垂直线.我发现了如何通过 http://t16web.lanl.gov/Kawano/gnuplot/parametric-e.html

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

我想要

const=repititionperiod*i

其中i是属于(1,calculateduppedlimit]的整数.

where i is an integer belonging to (1,calculateduppedlimit].

我可以通过sed再次输入repititionperiod,并且类似的徒然计算出来的uppedlimit,但是需要某种形式的for循环,无论是在gnuplot内还是单独的gnuplot脚本,该脚本都会在我的bash脚本中的for循环内为已创建的绘图添加一条垂直线.

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.

我找不到有关gnu图内循环或添加到先前创建的图上的循环的任何信息.

I can't find any information on loops within gnu plot or adding to a previously created plot.

非常感谢收到任何建议.

Any advice gratefully received.

推荐答案

实际上,Gnuplot现在确实支持for循环,您可以阅读

Gnuplot does now in fact now support a for loop, you can read about it here

据我所知,gnuplot没有for循环,尽管您可以生成如下所示的一种:

As I understand gnuplot doesn't have a for loop, although you can generate one of sorts as follows:

制作一个包含以下内容的文件"loop.gp"

Make a file "loop.gp" containing

const  = const + 1
#... some gnuplot commands ... 
if(const<100) reread

然后在gnuplot终端或脚本编写中

then in a gnuplot terminal, or script write,

const = 3; load "loop.gp";

这将为您提供一个简单的循环.

This will give you a simple loop.

(此示例摘自对于您的特定答案,您可以尝试添加箭头而不是参数线, 例如.

For your particular answer you might try adding arrows rather than paremetric lines, eg.

set arrow from const,1 to const,4 nohead

将做同样的事情.

在这种情况下,您的loop.gp可能是

In this case you loop.gp could be

const  = const + repititionperiod
#... some gnuplot commands ...  
set arrow from const,1 to const,4 nohead
if(const<calculatedupperlimit) reread

,您将使用

const = 1; repititionperiod=2;calculatedupperlimit = 10; load "loop.gp"; replot;

重复绘图绘制箭头.

如果您只是"想要线条而没有其他内容-那么您将需要提供一个图表以进行实际绘制(一组箭头不计算在内).然后,您所提供的示例可用于绘制第一条垂直线.

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.

希望这会有所帮助.

汤姆

这篇关于Gnuplot脚本,用于在内部绘图中循环或添加到现有绘图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆