gnuplot中带有参数图的for循环 [英] for loop with parametric plots in gnuplot
问题描述
我试图在gnuplot 4.6中绘制多个参数曲线.
在早期版本(4.4?)中,命令
set para
plot [-pi:pi] for [a=1:10] a*cos(t),a*sin(t)
将得到十个以原点为中心,半径为1、2,...,10的圆.在4.6中,结果为一个半径为1的圆.
在4.6中,命令
unset para
plot [-pi:pi] for [a=1:10] a*sin(x)
产生十条漂亮的正弦曲线.所以,我想看来"for"命令现在在参数曲线图绘制方面存在问题.
有人知道解决方法吗?圆形对象对我没有用:我对一般曲线感兴趣.谢谢!
参数模式和迭代之间的语法歧义是当前gnuplot版本中已记录的错误/局限性.在开发版本(4.7)中,不需要单独的参数模式,因为所需的采样变量可以在通用plot命令中明确描述:
plot for [a=1:10] [t=-10:10] '+' using (a*sin(t)):(a*cos(t))
不幸的是,完全通用的语法在4.6版中不可用.我能想到的最接近的是一个更简单的变体:
unset parametric
plot for [a=1:10] '+' using (a*sin($1)):(a*cos($1))
这适用于您的示例案例,但可能不足以满足您的实际用例,因为它将参数变量上的采样范围与x上的隐式绘图范围相结合.
I am trying to plot multiple parametric curves in gnuplot 4.6.
In an earlier version (4.4?), the commands
set para
plot [-pi:pi] for [a=1:10] a*cos(t),a*sin(t)
would result in ten circles centered at the origin with radius 1, 2, ..., 10. In 4.6, the result is one circle of radius 1.
In 4.6, the commands
unset para
plot [-pi:pi] for [a=1:10] a*sin(x)
yield ten beautiful sine curves.
So, it appears that the "for" command now has a problem with parametric curve plotting, I guess.
Does anyone know of a workaround? The circle object is not useful for me: I am interested in general curves. Thanks!
The syntax ambiguity between parametric mode and iteration is a documented bug/limitation in current gnuplot versions. In the development version (4.7) a separate parametric mode is not necessary, as the required sampling variable can be explicitly described in a generic plot command:
plot for [a=1:10] [t=-10:10] '+' using (a*sin(t)):(a*cos(t))
Unfortunately that fully general syntax is not available in version 4.6. The closest I can think of is a simpler variant:
unset parametric
plot for [a=1:10] '+' using (a*sin($1)):(a*cos($1))
This works for your example case, but may not suffice for your actual use case because it conflates the sampling range on the parametric variable with the implicit plotting range on x.
这篇关于gnuplot中带有参数图的for循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!