使用' - '绘制多个列

时间:2013-02-06 09:08:35

标签: gnuplot

我试图找出如何使以下代码工作而不必多次打印数据(并用'e'分隔副本):

plot '-' using 1:2, '-' using 1:3
-1 0.000679244 0.000246399
-0.99875 0.000687629 0.000251162
-0.9975 0.000696107 0.000256024
-0.99625 0.000704678 0.000260987
-0.995 0.000713343 0.000266052
-0.99375 0.000722103 0.000271221
-0.9925  0.00073096 0.000276496
-0.99125 0.000739913 0.000281879
-0.99 0.000748965 0.000287372

上面的代码生成错误消息:

warning: Skipping data file with no valid points

我知道,我可以将数据写入文件并多次调用plot 'file'。有办法避免这种情况吗?谢谢!

2 个答案:

答案 0 :(得分:1)

没有(好的)方法可以做到这一点。这是一个非常难看的黑客:

s = "-1 0.000679244 0.000246399\n-0.99875 0.000687629 0.000251162\n-0.9975 0.000696107 0.000256024\n-0.99625 0.000704678 0.000260987\n-0.995 0.000713343 0.000266052\n-0.99375 0.000722103 0.000271221\n-0.9925  0.00073096 0.000276496\n-0.99125 0.000739913 0.000281879\n-0.99 0.000748965 0.000287372"

plot sprintf('<echo "%s"',s) using 1:2, sprintf('<echo "%s"',s) using 1:3

似乎我们可以通过在字符串中使用行继续来使它看起来更漂亮......:

inline_file ="\
-1 0.000679244 0.000246399\n \
-0.99875 0.000687629 0.000251162\n \
-0.9975 0.000696107 0.000256024\n \
-0.99625 0.000704678 0.000260987\n \
-0.995 0.000713343 0.000266052\n \
-0.99375 0.000722103 0.000271221\n \
-0.9925  0.00073096 0.000276496\n \
-0.99125 0.000739913 0.000281879\n \
-0.99 0.000748965 0.000287372"

plot sprintf('<echo "%s"',inline_file) using 1:2, \
     sprintf('<echo "%s"',inline_file) using 1:3

答案 1 :(得分:0)

由于5.0版gnuplot支持数据块,因此可以更好地处理内联数据:

$data <<EOD
-1 0.000679244 0.000246399
-0.99875 0.000687629 0.000251162
-0.9975 0.000696107 0.000256024
EOD
plot $data u 1:2, '' u 1:3