Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #1034

Re: Realtime plot-C++ showing previous 5 values

From sfeam <sfeam@users.sourceforge.net>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: Realtime plot-C++ showing previous 5 values
Followup-To comp.graphics.apps.gnuplot
Date 2012-04-12 23:16 -0700
Organization gnuplot development team
Message-ID <jm8gce$j56$1@dont-email.me> (permalink)
References <4c34c399-5c77-4085-892e-2124e3b63337@gh10g2000pbc.googlegroups.com>

Followups directed to: comp.graphics.apps.gnuplot

Show all headers | View raw


lakskant wrote:

> Dear all,
> 
> I have successfully integrated my c++ program which scans values from
> a laser scanner and gnuplot in real time. It can plot the values in a
> single window. I used this code.
> 
> string command =  "set multiplot \n" ;
>   char *path = "\"C:\\Program Files\\gnuplot\\bin\\gnuplot\"";
> 
>   gp = _popen(path , "w");
> 
>   if (gp == NULL)
> 
>     return -1;
> 
>  fprintf(gp,"set multiplot\n");

Why multiplot?


>  fprintf(gp,"set origin 0,0\n");
>  if (scancount ==1)
> {
> fprintf(gp, "plot '-' u 1:2 w points\n");
> }
>  else
> {
>  fprintf(gp, "plot '-' u 1:2 w points\n");
> }

These two commands seem to be the same.  Typo?


>  for (int i=0;i<80;i++)
>  fprintf(gp, "%lf %lf\n",afx[i],afy[i]);
>  fprintf(gp, "e\n");
>   fflush(gp);
> 
> 
> Now I want to only display last 5 scan values on a same window. My
> solution is to write the values in a temp file and plotting it from
> there.
> 
> Is there any better efficient solution.

I am afraid I don't quite understand what you are trying to do.
For one thing I don't understand whether there is only one 
scanned data set, or a new one every few seconds, or what.

Yes, you could write the data to a separate file and then 
have gnuplot read the data from the file.  You could even
replace the contents of the file asynchronously and have
gnuplot refresh the display by sending it a "replot"
command.

As to doing something special with the previous N data points,
you might have a look at:
  http://gnuplot.sourceforge.net/demo/running_avg.html




Back to comp.graphics.apps.gnuplot | Previous | NextPrevious in thread | Find similar


Thread

Realtime plot-C++ showing previous 5 values lakskant <plkant87@gmail.com> - 2012-04-12 18:41 -0700
  Re: Realtime plot-C++ showing previous 5 values sfeam <sfeam@users.sourceforge.net> - 2012-04-12 23:16 -0700

csiph-web