0

There have been several posts. However, in most cases people suggested to use some gnuplot interfaces or perl script. In my case, I don't want to use them and implement my own solution. I wish to plot in realtime data in array.

Here is the scenario. I have an array of data let's suppose [pt1, pt2, pt3 .... n]. I know the value of n. At one point in time T1. I want to plot these values. I know that I can do that by:

gp = _popen("C:\\gnuplot\\gnuplot -persist", "w");

/* I can use a loop to generate the following string */

fprintf(gp, "plot \"-\" using 1:2 w points, \ \"-\" using 1:3 w points\n"...,\   \"-\" using 1:n w points\n");

Just for the sake of example, for now suppose we have two elements in array one at a time:

T1 pt1  pt2 //I want to plot is at T1
T2 pt3  pt4 //I want to plot this at T2 on the same graph

Using the code below I can plot T1:

fprintf(gp, "1.0 1.2 2.2\n");
fprintf(gp, "end\n");
fflush(gp);
fprintf(gp, "1.0 1.2 2.2\n");
fprintf(gp, "end\n");
fflush(gp);

But i can't seem to print T2 on the same graph:

fprintf(gp, "1.1 1.3 2.1\n");
fprintf(gp, "end\n");
fflush(gp);
fprintf(gp, "1.1 1.2 2.3\n");
fprintf(gp, "end\n");
fflush(gp);

Using fprintf(gp, "plot \"-\" using 1:2 w points, \ \"-\" using 1:3 w points\n"...,\ \"-\" using 1:n w points\n"); between T1 and T2 allows me to plot the second points. However, T1 plot is lost. So.how can I do that?

Thor
  • 45,082
  • 11
  • 119
  • 130
mustafa
  • 1
  • 2
  • Here is a similar question: http://stackoverflow.com/q/4585770/1331399 – Thor Feb 10 '15 at 13:20
  • If you are using Gnuplot 5 you could pass the data on as in-line data, there is an example here: http://stackoverflow.com/a/25059212/1331399 – Thor Feb 10 '15 at 13:30

0 Answers0