从 C 程序与 gnuplot 交互。如何输入数组进行绘图
Interacting with gnuplot from a C program. How to type in an array to plot
我正在尝试使用 gnuplot 制作一个嵌入到 C 应用程序中的 'live' 图,但我遇到了一些我想更改的内容。
我将 gnuplot_i 到 'interface' 与 gnuplot 一起使用,就像我在终端中使用 gnuplot 一样。
每当我绘制(两行)时,我都会将数据保存到一个文件中,然后告诉 gnuplot 加载文件并绘制。
我希望不必保存数据文件并将数据直接加载到 gnuplot 中。我对 gnuplot 了解不多,所以可能有一个简单的解决方案来满足我的需求。我想要的是这样的命令:
plot [1,2,3,4], [1,1,1,1], [1,2,3,4], [2,2,2,2]
|_____line 1_______| |______line 2______|
有没有办法在 gnuplot 中做到这一点?
gnuplot> help datablock
There are two mechanisms for embedding data into a stream of gnuplot commands.
If the special filename '-' appears in a plot command, then the lines
immediately following the plot command are interpreted as inline data.
See `special-filenames`. Data provided in this way can only be used once, by
the plot command it follows.
The second mechanism defines a named data block as a here-document. The named
data is persistent and may be referred to by more than one plot command.
Example:
$Mydata << EOD
11 22 33 first line of data
44 55 66 second line of data
# comments work just as in a data file
77 88 99
EOD
stats $Mydata using 1:3
plot $Mydata using 1:3 with points, $Mydata using 1:2 with impulses
Data block names must begin with a $ character, which distinguishes them from
other types of persistent variables. The end-of-data delimiter (EOD in the
example) may be any sequence of alphanumeric characters.
我正在尝试使用 gnuplot 制作一个嵌入到 C 应用程序中的 'live' 图,但我遇到了一些我想更改的内容。
我将 gnuplot_i 到 'interface' 与 gnuplot 一起使用,就像我在终端中使用 gnuplot 一样。 每当我绘制(两行)时,我都会将数据保存到一个文件中,然后告诉 gnuplot 加载文件并绘制。
我希望不必保存数据文件并将数据直接加载到 gnuplot 中。我对 gnuplot 了解不多,所以可能有一个简单的解决方案来满足我的需求。我想要的是这样的命令:
plot [1,2,3,4], [1,1,1,1], [1,2,3,4], [2,2,2,2]
|_____line 1_______| |______line 2______|
有没有办法在 gnuplot 中做到这一点?
gnuplot> help datablock
There are two mechanisms for embedding data into a stream of gnuplot commands.
If the special filename '-' appears in a plot command, then the lines
immediately following the plot command are interpreted as inline data.
See `special-filenames`. Data provided in this way can only be used once, by
the plot command it follows.
The second mechanism defines a named data block as a here-document. The named
data is persistent and may be referred to by more than one plot command.
Example:
$Mydata << EOD
11 22 33 first line of data
44 55 66 second line of data
# comments work just as in a data file
77 88 99
EOD
stats $Mydata using 1:3
plot $Mydata using 1:3 with points, $Mydata using 1:2 with impulses
Data block names must begin with a $ character, which distinguishes them from
other types of persistent variables. The end-of-data delimiter (EOD in the
example) may be any sequence of alphanumeric characters.