有人可以解释为什么第二条曲线不仅是从0,0
到1,1
的预期线,而是从0,0
到2*pi,2*pi
的线吗?为什么忽略第二个范围[t=0:1]
?
错误或功能,或者我错过了手册中的任何内容?
代码:
### parametric curves
reset session
set parametric
set size square
plot [0:2*pi] cos(t), sin(t) w l, \
[t=0:1] t, t w l
### end of code
结果:
答案 0 :(得分:1)
在绘图命令开始时使用轴范围是历史产物。它使程序以及用户感到困惑,并且由于在版本5中引入了采样范围,因此可能导致语法不明确。要消除语法歧义,可以将关键字sample
放在第一个绘图组件的范围说明符之前:
set style data linespoints
set key left
plot sample [14:22:2] '+' u 1:1 pt "1" ti "sub-plot 1 sample interval 2", \
[1:12:1] '+' u 1:1 pt "2" ti "sub-plot 2 sample interval 1", \
[33:66:6] '+' u 1:1 pt "3" ti "sub-plot 3 sample interval 6"
答案 1 :(得分:0)
让我总结一下我的学识,我对范围,样本和参数有些困惑。
我想要实现的目标如下:
通过一条绘图命令3条具有不同范围和不同样本的曲线。例如进行说明:
经验教训:
parametric
处于关闭状态,则它不允许(给出错误)在第一个plot命令中指定[start:end:step]
,而在第二和第三个(子)plot命令中允许。奇怪。parametric
处于打开状态,则第一个绘图命令中的step
将被忽略,并且样本数量将由前一个set samples
定义。不太明显。parametric
关闭,我将无法达到预期的效果。set parametric
一起使用[start:end:step] '+' u ...
长话短说。像这样编码时,我可以达到预期的结果:
set parametric
set samples samples1 # because step1 will be ignored
plot [start1:end1:step1] '+' u (<whatever>):(<whatever>) ti "sub-plot 1", \
[start2:end2:step2] '+' u (<whatever>):(<whatever>) ti "sub-plot 2", \
[start3:end3:step3] '+' u (<whatever>):(<whatever>) ti "sub-plot 3"
下面的代码和图形显示带有/不带有parametric
的不同选项以及3条曲线的不同顺序。
下图只有底行显示了所需的结果。
代码:
### curves with different ranges & samples within one plot command
reset session
set colorsequence classic
Random = "[0:1:0.001] '+' u (2*rand(0)):(2*rand(0)) w p pt 7 ps 0.5 not"
RandomFirst = "[0:1] '+' u (2*rand(0)):(2*rand(0)) w p pt 7 ps 0.5 not"
Circle = "[0:2*pi:pi/12] '+' u (cos($1)):(sin($1)) w lp pt 7 not"
CircleFirst = "[0:2*pi] '+' u (cos($1)):(sin($1)) w lp pt 7 not"
Line = "[-0.5:0.5:0.5] '+' u 1:1 w lp pt 7 lw 2 not"
LineFirst = "[-0.5:0.5] '+' u 1:1 w lp pt 7 lw 2 not"
set multiplot layout 4,3 columnsfirst
set label 1 "random/circle/line" at screen 0.166,0.99 center
unset parametric
set title "parametric OFF"
plot @RandomFirst, @Circle, @Line
set parametric
set title "parametric ON"
plot @Random, @Circle, @Line
unset parametric
set samples 1000
set title "parametric OFF"
plot @RandomFirst, @Circle, @Line
set parametric
set title "parametric ON"
plot @Random, @Circle, @Line
set label 2 "line/random/circle" at screen 0.5,0.99 center
unset parametric
set title "parametric OFF"
plot @LineFirst, @Random, @Circle
set parametric
set title "parametric ON"
plot @Line, @Random, @Circle
set samples 3
unset parametric
set title "parametric OFF"
plot @LineFirst, @Random, @Circle
set parametric
set title "parametric ON"
plot @Line, @Random, @Circle
set label 3 "circle/line/random" at screen 0.833,0.99 center
unset parametric
set title "parametric OFF"
plot @CircleFirst, @Line, @Random,
set parametric
set title "parametric ON"
plot @Circle, @Line, @Random,
set samples 24
unset parametric
set title "parametric OFF"
plot @CircleFirst, @Line, @Random,
set parametric
set title "parametric ON"
plot @Circle, @Line, @Random,
unset multiplot
### end of code
结果: