3
我想绘制每秒更改的图形。我使用下面的代码,它会定期更改图形。但是每次迭代都不会保留先前的迭代点。我该怎么做? 每秒只有一分。但我想用历史数据绘制图表。Gnuplot - 每秒更新图形
FILE *pipe = popen("gnuplot -persist", "w");
// set axis ranges
fprintf(pipe,"set xrange [0:11]\n");
fprintf(pipe,"set yrange [0:11]\n");
int b = 5;int a;
for (a=0;a<11;a++) // 10 plots
{
fprintf(pipe,"plot '-' using 1:2 \n"); // so I want the first column to be x values, second column to be y
// 1 datapoints per plot
fprintf(pipe, "%d %d \n",a,b); // passing x,y data pairs one at a time to gnuplot
fprintf(pipe,"e \n"); // finally, e
fflush(pipe); // flush the pipe to update the plot
usleep(1000000);// wait a second before updating again
}
// close the pipe
fclose(pipe);
谢谢!此代码是工作。但是这个解决方案不是基于gnuplot。我试图找到一个基于gnuplot命令的解决方案。如果我找不到它,我使用此代码。非常感谢你。 – zumma 2014-12-07 13:51:18