我已经制作了一个脚本来使用gnuplot绘制一些线条。我的脚本如下:
#!/usr/local/bin/gnuplot
reset
set terminal wxt
set yrange [0:100]
set xrange [0:100]
unset colorbox
set style arrow 1 nohead lc rgb 'black'
set style arrow 2 nohead lc rgb 'red'
set arrow 1 from 1,10 to 2,10 nohead
plot [0:15][0:22]-0.2*x+7.8
set arrow 1 from 2,15 to 3,15 nohead
plot [0:15][0:22]-0.2*x+12.8
set arrow 1 from 3,20 to 4,20 nohead
plot [0:15][0:22]-0.2*x+17.8
我想绘制所有三条线,但是当我运行它时,我只得到一行作为输出。脚本有什么问题吗?
答案 0 :(得分:1)
您只需要发出一个plot
命令:
#!/usr/local/bin/gnuplot
reset
set terminal wxt
set yrange [0:100]
set xrange [0:100]
set style arrow 1 nohead lc rgb 'black'
set style arrow 2 nohead lc rgb 'red'
set arrow 1 from 1,10 to 2,10 nohead
set arrow 2 from 2,15 to 3,15 nohead
set arrow 3 from 3,20 to 4,20 nohead
plot [0:15][0:22] -0.2*x+7.8, \
-0.2*x+12.8, \
-0.2*x+17.8
答案 1 :(得分:0)
不同的箭头必须具有不同的索引。因此,请使用set arrow 1 ...
,set arrow 2 ...
和set arrow 3 ...
,而不是三次指定set arrow 1 ...
。
脚本中的其他几点:
set style arrow
定义的样式将分配给带有arrowstyle
关键字的箭头。 所以可以使用它:
set style arrow 1 nohead lc rgb 'black'
set style arrow 2 nohead lc rgb 'red'
set style arrow 3 nohead lc rgb 'green'
set arrow 1 from 1,10 to 2,10 arrowstyle 1
set arrow 2 from 2,15 to 3,15 arrowstyle 2
set arrow 3 from 3,20 to 4,20 arrowstyle 3
plot [0:15][0:22]-0.2*x+7.8 ,\
-0.2*x+12.8 ,\
-0.2*x+17.8
或者这个:
set arrow 1 from 1,10 to 2,10 nohead lc rgb 'black'
set arrow 2 from 2,15 to 3,15 nohead lc rgb 'red'
set arrow 3 from 3,20 to 4,20 nohead lc rgb 'green'
plot [0:15][0:22]-0.2*x+7.8 ,\
-0.2*x+12.8 ,\
-0.2*x+17.8
set xrange [0:100]
被[0:15]
命令中的plot
覆盖。 yrange
。colorbox
仅在pm3d情节