在同一个 gnuplot 中绘制多个数据集 window
Plotting multiple dataset in same gnuplot window
我有两个数据集 (x,y1) 和 (x,y2),它们是我从计算结果中得到的,并将这些文件写入“data1.tmp”和“data2.tmp”。我想用这两个数据集在 Gnuplot 中绘图。
#include <iostream>
#include <cstdlib>
int main()
{
FILE* gnupipe1, *gnupipe2;
const char* GnuCommands1[] = {"set title \"v vs x\"","plot \'data1.tmp\' with lines"};
const char* GnuCommands2[] = {"set title \"y vs x\"","plot \'data2.tmp\' with lines"};
gnupipe1 = _popen("gnuplot -persistent","w");
gnupipe2 = _popen("gnuplot -persistent", "w");
for (int i = 0; i < 2; i++)
{
fprintf(gnupipe1,"%s\n",GnuCommands1[i]);
fprintf(gnupipe2,"%s\n", GnuCommands2[i]);
}
return 0;
}
现在,当我 运行 程序二 window 出现时,可以准确地绘制数据。
如何绘制多个数据集?在同一个 window?
中说 (x,y1) & (x,y2)
您正在打开两个不同的 gnuplots,您不需要这样做。
#include <iostream>
#include <cstdlib>
int main()
{
FILE* gnupipe1;
const char* GnuCommands1[] = {"set title \"v vs x\"",
"plot \'data1.tmp\' with lines, \'data2.tmp\' with lines"};
gnupipe1 = _popen("gnuplot -persistent","w");
for (int i = 0; i < 2; i++)
fprintf(gnupipe1,"%s\n",GnuCommands1[i]);
return 0;
}
我有两个数据集 (x,y1) 和 (x,y2),它们是我从计算结果中得到的,并将这些文件写入“data1.tmp”和“data2.tmp”。我想用这两个数据集在 Gnuplot 中绘图。
#include <iostream>
#include <cstdlib>
int main()
{
FILE* gnupipe1, *gnupipe2;
const char* GnuCommands1[] = {"set title \"v vs x\"","plot \'data1.tmp\' with lines"};
const char* GnuCommands2[] = {"set title \"y vs x\"","plot \'data2.tmp\' with lines"};
gnupipe1 = _popen("gnuplot -persistent","w");
gnupipe2 = _popen("gnuplot -persistent", "w");
for (int i = 0; i < 2; i++)
{
fprintf(gnupipe1,"%s\n",GnuCommands1[i]);
fprintf(gnupipe2,"%s\n", GnuCommands2[i]);
}
return 0;
}
现在,当我 运行 程序二 window 出现时,可以准确地绘制数据。
如何绘制多个数据集?在同一个 window?
中说 (x,y1) & (x,y2)您正在打开两个不同的 gnuplots,您不需要这样做。
#include <iostream>
#include <cstdlib>
int main()
{
FILE* gnupipe1;
const char* GnuCommands1[] = {"set title \"v vs x\"",
"plot \'data1.tmp\' with lines, \'data2.tmp\' with lines"};
gnupipe1 = _popen("gnuplot -persistent","w");
for (int i = 0; i < 2; i++)
fprintf(gnupipe1,"%s\n",GnuCommands1[i]);
return 0;
}