【问题标题】:Gnuplot: Plotting several datasets with titles from the pipeGnuplot:用管道中的标题绘制几个数据集
【发布时间】:2016-05-24 14:55:29
【问题描述】:

作为Gnuplot: Plotting several datasets with titles from one file 的后续行动,我有一个test.dat 文件:

"p = 0.1"
1 1
3 3
4 1


"p = 0.2"
1 3
2 2
5 2

我可以使用以下方法在 gnuplot 中毫无问题地绘制它:

> plot for [IDX=0:1] 'test.dat' i IDX u 1:2 w lines title columnheader(1)

但是我无法通过管道传输数据。

这是单行示例:

$ cat test.dat | gnuplot --persist -e "plot for [IDX=0:1] '-' i IDX u 1:2 w lines title columnheader(1)"
line 10: warning: Skipping data file with no valid points

我收到警告消息,并且只绘制了第一组。我试图在数据文件的末尾添加一个e,但没有运气......这应该是微不足道的,我犯了一个愚蠢的错误吗?


我又搞砸了。所以这些工作:

gnuplot --persist -e "plot for [IDX=0:1] 'test.dat' i IDX u 1:2 w lines title columnheader(1)"
gnuplot --persist -e "plot for [IDX=0:1] '< cat test.dat' i IDX u 1:2 w lines title columnheader(1)"

这些不:

cat test.dat | gnuplot --persist -e "plot for [IDX=0:1] '-' i IDX u 1:2 w lines title columnheader(1)"
cat test.dat | gnuplot --persist -e "plot for [IDX=0:1] '< cat' i IDX u 1:2 w lines title columnheader(1)"

对我来说它看起来像一个错误。我尝试了几个 Gnuplot 版本(4.6.6、5.0.0、5.0.3),但它们都表现出相同的行为。

【问题讨论】:

  • 是否适合使用 gnuplot &lt; 文件名关键字从管道获取数据?它是这样工作的吗?
  • @bibi 不是真的,因为我正在从另一个进程流式传输数据,但是是的 plot '&lt; cat test.dat' 工作......多么奇怪的问题!我应该能够通过磁盘轻松解决,但管道应该也可以工作。
  • 我还是不明白为什么不在 gnuplot 中运行你的命令
  • @bibi 那是因为我想发布一个 Python 脚本。按照你的建议去做迫使我发布一个 Python 和一个 Gnuplot 脚本,而用户需要启动后者,这可能会令人困惑,因为它违反了我以前的标准。

标签: dataset pipe gnuplot


【解决方案1】:

好的,我终于可以浏览文档了。管道时,每个索引选择都需要重复整个数据:

plot '-' index 0, '-' index 1
2
4
6


10
12
14
e
2
4
6


10
12
14
e

或者,作为一种更简单的选择,你可以这样做:

plot '-', '-'
2
4
6
e
10
12
14
e

【讨论】:

    猜你喜欢
    • 2014-01-07
    • 1970-01-01
    • 2023-02-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多