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


Groups > comp.graphics.apps.gnuplot > #2252 > unrolled thread

problem piping commands to gnuplot under Windows

Started byJohn Edwards <johned0@gmail.com>
First post2014-01-12 00:19 +0000
Last post2014-01-12 08:17 +0000
Articles 2 — 1 participant

Back to article view | Back to comp.graphics.apps.gnuplot


Contents

  problem piping commands to gnuplot under Windows John Edwards <johned0@gmail.com> - 2014-01-12 00:19 +0000
    Re: problem piping commands to gnuplot under Windows John Edwards <johned0@gmail.com> - 2014-01-12 08:17 +0000

#2252 — problem piping commands to gnuplot under Windows

FromJohn Edwards <johned0@gmail.com>
Date2014-01-12 00:19 +0000
Subjectproblem piping commands to gnuplot under Windows
Message-ID<bje5c6F7tvaU1@mid.individual.net>
Hello again folks,

I am trying to plot two data files using the following code :

#include <stdlib.h>
#include <stdio.h>

void main()
{
   FILE * gnuplotPipe = _popen ("gnuplot -persist", "w");
   FILE * f1 = fopen("1.tmp", "w");
   FILE * f2 = fopen("2.tmp", "w");
   int i;

   for (i = 0; i < 5; i++)
   {
     fprintf (f1, "%lf %lf\n", (float)i, (float)i);
     fprintf (f2, "%lf %lf\n", (float)i, (float)i+1);
   }
   fclose (f1); fclose (f2);

   fprintf (gnuplotPipe, "plot \"1.tmp\" using 1:2 title \"Data set 0\" 
with lines lc rgb \"purple\", \\\n");
   fprintf (gnuplotPipe, " \"2.tmp\" using 1:2 title \"Data set 1\" with 
lines lc rgb \"green\"\n");
   fflush (gnuplotPipe);
   getchar ();
   fprintf (gnuplotPipe, "exit\n");
   _pclose (gnuplotPipe);
}

This works fine if I run the plot command in gnuplot from a script or if 
I use pgnuplot but when I use gnuplot I get the following error message :

gnuplot> plot "1.tmp" using 1:2 title "Data set 0" with lines lc rgb 
"purple", \
 >
gnuplot>  '2.tmp' using 1:2 title "Data set 1" with lines lc rgb "green"
          ^
          invalid command

Can anyone tell me if I am being a numpty ?

Thanks very much,
John

[toc] | [next] | [standalone]


#2253

FromJohn Edwards <johned0@gmail.com>
Date2014-01-12 08:17 +0000
Message-ID<bjf1ciFd0kqU1@mid.individual.net>
In reply to#2252
I had a bit of a lightbulb moment while waking up this morning and 
wondered if it was a CR/LF problem and sure enough the following code 
works fine :

fprintf (gnuplotPipe, "plot \"1.tmp\" using 1:2 title \"Data set 0\" 
with lines lc rgb \"purple\", \\\r");

Note the \r rather than \n.
Does anyone think this should be reported as a bug ?
Cheers,
John


On 12/01/2014 00:19, John Edwards wrote:
> Hello again folks,
>
> I am trying to plot two data files using the following code :
>
> #include <stdlib.h>
> #include <stdio.h>
>
> void main()
> {
>    FILE * gnuplotPipe = _popen ("gnuplot -persist", "w");
>    FILE * f1 = fopen("1.tmp", "w");
>    FILE * f2 = fopen("2.tmp", "w");
>    int i;
>
>    for (i = 0; i < 5; i++)
>    {
>      fprintf (f1, "%lf %lf\n", (float)i, (float)i);
>      fprintf (f2, "%lf %lf\n", (float)i, (float)i+1);
>    }
>    fclose (f1); fclose (f2);
>
>    fprintf (gnuplotPipe, "plot \"1.tmp\" using 1:2 title \"Data set 0\"
> with lines lc rgb \"purple\", \\\n");
>    fprintf (gnuplotPipe, " \"2.tmp\" using 1:2 title \"Data set 1\" with
> lines lc rgb \"green\"\n");
>    fflush (gnuplotPipe);
>    getchar ();
>    fprintf (gnuplotPipe, "exit\n");
>    _pclose (gnuplotPipe);
> }
>
> This works fine if I run the plot command in gnuplot from a script or if
> I use pgnuplot but when I use gnuplot I get the following error message :
>
> gnuplot> plot "1.tmp" using 1:2 title "Data set 0" with lines lc rgb
> "purple", \
>  >
> gnuplot>  '2.tmp' using 1:2 title "Data set 1" with lines lc rgb "green"
>           ^
>           invalid command
>
> Can anyone tell me if I am being a numpty ?
>
> Thanks very much,
> John
>
>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.graphics.apps.gnuplot


csiph-web