|
From: Stephen W. <ste...@in...> - 2012-02-19 14:37:39
|
Allan Felipe wrote:
> Hi, I would like to plot a set of points which is being generated by a C
> code, using pipe. It would plot a sequence of these points making a video.
> Here is an example that does the job:
>
> ----------------------------------------------------------------
>
> #include<stdio.h>
> #include<stdlib.h>
> #include<unistd.h>
>
> int main() {
>
> FILE *pipe;
> pipe = popen("gnuplot -persist", "w");
>
> fprintf(pipe, "set xlabel 'x (m)' \n");
> fprintf(pipe, "set ylabel 'y (m)' \n");
> fprintf(pipe, "set pointsize 1 \n");
> fprintf(pipe, "set xrange[-0.1:4.1] \n");
> fprintf(pipe, "set yrange[-0.1:4.1] \n");
>
> int i;
> double x, y;
>
> for (i = 1; i< 30; i++) {
> x = (double) rand() / RAND_MAX;
> y = (double) rand() / RAND_MAX;
>
> fprintf(pipe, "plot '< echo %lf, %lf' w p pt 7 lc -1 notitle \n",
> 4*x, 4*y);
>
> fflush(pipe);
> usleep(150000);
> }
>
> fclose(pipe);
> return 0;
> }
>
> -------------------------------------------------------------------------------------
>
> It works ... however, the way it is done, it plots just one point at a time.
> I would like to plot one point, then another one, but keeping the last point
> ... then another, keeping all the other 2 ... so I'd like to know how I
> could add one point to a graph that is already done, that would solve my
> problem.
>
I make animations using a fortran calling code
for each time step (while the code is ececuting).
call SYSTEM("/usr/bin/gnuplot explosion.gnu")
Each time step adds an additional point.
Hope this helps,
Stephen
--
ste...@in...
2004 route des lucioles - BP93
Sophia Antipolis
06902 CEDEX
Tel: 04 92 38 50 54
Fax: 04 97 15 53 51
|