GNUPLOT:如何使用函数来决定绘图风格 [英] GNUPLOT: How to use a function to decide the plot style

查看:108
本文介绍了GNUPLOT:如何使用函数来决定绘图风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多系列来绘制一个情节。我想根据一系列的数量来决定情节风格/类型。这是我想要的示例代码:

  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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆