【问题标题】:Piping to gnuplot, doesn't accept multiple commands管道到 gnuplot,不接受多个命令
【发布时间】:2012-03-21 23:41:03
【问题描述】:

我有以下代码:

fprintf(temp->_fstream, "plot '-' using 1:2 title 'tittle1'\n");

_fstream 是一个 gnuplot 管道,使用“-”可以直接将数据写入 gnuplot,而不是先将其写入文件,这是执行此操作的代码:

 fprintf    (_stream->_fstream, "%d ", _node->count);

现在我想以 1:3 的比例绘制另外两列,例如在 gnuplot 中,您可以使用:

plot "output3.txt" using 1:2 title 'prey', "output3.txt" using 1:3 title 'predator'

但是通过管道做同样的事情它会给出一个错误说unreachable data source这是我正在使用的行:

fprintf(temp->_fstream, "plot '-' using 1:2 title 'tittle1', '-' using 1:3 ... \n");

我已经研究了一段时间,如果有任何帮助,将不胜感激。

【问题讨论】:

  • 您可能需要创建一个伪 TTY 以使 gnuplot 的行为就像它处于交互模式一样。

标签: c stream pipe gnuplot popen


【解决方案1】:

试试这个:

plot '-' us 1:2, '' us 1:2

并输入(或写入流)数据,后跟“e”。 然后,输入第二组数据,后跟“e”。

1 1
2 2
3 3
e
1 2
2 3
3 4
e

【讨论】:

  • 感谢您的回复,是的,我想我将不得不重新输入数据,上面的行不起作用,唯一的问题是数据> 10,000,因此重新输入会很昂贵。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-08
  • 1970-01-01
  • 2013-08-01
  • 1970-01-01
相关资源
最近更新 更多