仓库源文站点原文


layout: post title: gnuplot直接数据作图 categories:


2014-02-21 10:51:17

利用特殊文件名"-", 可指示gnuplot从输入端读入数据, 但默认只读一遍, 所以多列数据同时作图时, 需要将数据列出多次. 新版4.7中可以使用命名数据块(named data block)解决这个问题.

<pre class="line-numbers" data-start="0"><code class="language-bash"># Language: bash gnuplot << EOF set term png; set out "gpl.png" plot '-' u 1:2, '-' u 1:3 1 2 3 4 5 6 7 8 9 e 1 2 3 4 5 6 7 8 9 e EOF </code></pre>

新版本可如下实现

<pre class="line-numbers" data-start="0"><code class="language-bash"># Language: bash gnuplot << EOF set term png; set out "gpl.png" $Mydata << EOD 11 22 33 44 55 66 77 88 99 EOD plot $Mydata u 1:3 w p, $Mydata u 1:2 w impulses EOF </code></pre>

参考

  1. Plot command with '-' and '' using same data Also
  2. Gnuplotting data without a textfile
  3. Gnuplotting multi-plot data without a textfile