GNUPLOT:如何使用函数来决定绘图风格 [英] GNUPLOT: How to use a function to decide the plot style
问题描述
title(i)= value(sprintf(title%i ,i))
title1 ='x'
title2 ='x ^ 2'
title3 ='x ^ 3'
...
(i)= value(sprintf(with%i,i))
with1 ='lines'
with2 ='points'
with3 ='boxes'
。 ..
为[i = 1:100]绘制的图形' - '标题标题(i)with with(i)
我测试了title()函数的工作原理。但with函数无法正常工作。
你能帮我修复代码吗?
或者您认为还有其他方法可以实现我的目标吗?
$ b
p =plot/> x linewidth 1
for [i = 1:10] {
p = p.sprintf(,x +%d linewidth%d,i,i + 1)
}
print p
eval(p)
打印命令的输出是:
plot x linewidth 1,x + 1 linewidth 2,x + 2 linewidth 3,...
这就是结果图:
取决于什么你最终希望,这可能是你的东西:
do for [i = 1:10] {
p = (i == 1?'myData.csv'with lines:)
p = p。(i == 2?'myData.csv'with steps:)
...
}
然而, ,这看起来很丑陋。
I have lots of series to draw in 1 plot. I want to decide the plot style/type according to the number of a series. Here is the example code of what I am aiming for:
title(i)=value(sprintf("title%i",i))
title1='x'
title2='x^2'
title3='x^3'
...
with(i)=value(sprintf("with%i",i))
with1='lines'
with2='points'
with3='boxes'
...
plot for [i=1:100] '-' title title(i) with with(i)
I have test the title() function works. But the with function does not work correctly.
Can you help me fix the code?
Or do you think there are other ways to achieve what I am aiming for?
It's possible to build a string of a plot command and then run this string:
p="plot x linewidth 1"
do for [i=1:10]{
p=p.sprintf(", x+%d linewidth %d", i, i+1)
}
print p
eval(p)
The output of the print command is:
plot x linewidth 1, x+1 linewidth 2, x+2 linewidth 3, ...
and this is the resulting plot:
Depending on what you finally want, this might be something for you:
do for [i=1:10]{
p=p.(i==1 ? "'myData.csv' with lines" : "")
p=p.(i==2 ? "'myData.csv' with steps" : "")
...
}
However, this looks pretty ugly.
这篇关于GNUPLOT:如何使用函数来决定绘图风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!