for loop with parametric plots in gnuplot

痴心易碎 提交于 2020-01-15 08:04:29

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/20895415/for-loop-with-parametric-plots-in-gnuplot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!