问题描述
我正在尝试使用gnuplot在C应用程序中嵌入一个“实时”绘图,但是遇到了一些我想更改的东西。
我正在使用gnuplot_i与gnuplot“接口”,就像在终端中使用gnuplot一样。 每当我绘制(两行)时,我都会将数据保存到文件中,然后告诉gnuplot加载文件并绘制。
我不想保存数据文件并将数据直接加载到gnuplot中。我对gnuplot不太了解,所以可能有一个简单的解决方案可以解决我想要的问题。我想要的是这样的命令:
plot [1,2,3,4],[1,1,1],[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.