我想创建一个包含三个图的gnuplot.数据应该是内联的(正如我想要的那样)
它应该如下所示:

目前我正在使用以下gnuplot脚本来创建绘图:
set terminal png
set output "test.png"
plot for[col=2:4] "data.txt" using 1:col title columnheader(col) with lines
Run Code Online (Sandbox Code Playgroud)
该文件data.txt是:
Generation Best Worst Average
0 2 1 0
1 3 1 2
2 4 3 3
3 4 3 3
4 6 3 4
5 7 4 5
6 9 6 7
7 10 6 9
8 10 5 6
9 11 6 8
10 12 7 9
Run Code Online (Sandbox Code Playgroud)
我想将data.txt传递给gnuplot而不是依赖于脚本中引用的数据文件.有点像cat data.txt | gnuplot plot.gnu.原因是,我有几个data.txt文件,不想plot.gnu为每个文件构建一个文件. …
对于那些已经使用了gnuplot和“ splot”命令的人,我认为这可能是一个非常简单的问题,但是由于现在是我使用该程序的第一天,我现在无法弄清楚。
我实现了将我的c ++项目链接到gnuplot,因此我可以使用以下格式创建Datafile.dat:
# Xcoord Ycoord Zcoord
1 2 1
2 1 1
3 1 1
3 2 2
3 3 3
Run Code Online (Sandbox Code Playgroud)
在我的C ++文件中,我这样做:
#include "gnuplot.h"
#include <iostream>
using namespace std;
int main() {
Gnuplot plot;
plot("set border 4095");
plot("splot \"C:/\\Users/\\lRaulMN/\\Desktop/\\Datafile.dat\" with lines");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这完美地工作,我明白了:

现在的问题是:考虑到我正在使用的5点,是否有任何方法可以在不必创建Datafile.dat的情况下绘制这些数字?
Because in the future, I'll have something like this in my code:
#include "gnuplot.h"
#include <iostream>
#include <vector>
using namespace std;
typedef struct {
double Time;
double X;
double Y;
double …Run Code Online (Sandbox Code Playgroud) 我刚刚阅读了没有文本文件的Gnuplotting数据,我想做同样的事情,但是有了一个"多情节".我目前有:
plot 'data.csv' using 1:3:2:6:5:7:xticlabels(8) with candlesticks title 'Quartiles' whiskerbars, \
'' using 1:4:4:4:4:4 with candlesticks lt -1 notitle
Run Code Online (Sandbox Code Playgroud)
我想内联数据data.csv.
我发现在gnuplot中,可以从一个文件中获取多个曲线/数据集:
splot "file.dat" using 1:2:3, splot "file.dat" using 1:4:5
Run Code Online (Sandbox Code Playgroud)
也可以将数据嵌入脚本中,如下所示:
splot "-" using 1:2:3
1 0 1
1 2 3
0.5 3 1.5
Run Code Online (Sandbox Code Playgroud)
但是,以下似乎不起作用:
splot "-" using 1:2:3, "-" using 1:4:5
1 0 1 4 4
1 2 3 3 4
0.5 3 1.5 2.5 -1
Run Code Online (Sandbox Code Playgroud)
这是故意的吗,是否存在解决方法?或者根本不可能吗?