Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: John Edwards Newsgroups: comp.graphics.apps.gnuplot Subject: Re: problem piping commands to gnuplot under Windows Date: Sun, 12 Jan 2014 08:17:20 +0000 Lines: 62 Message-ID: References: Reply-To: johned0@gmail.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 0UATN74WFfxLDCTOTDm9uwAdhcI5kNElcAUNPAR9CGMwPKMi7C Cancel-Lock: sha1:+nBOsKJQEKvRdzbL7v7V3+aFeiw= User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: Xref: csiph.com comp.graphics.apps.gnuplot:2253 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 > #include > > 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 > >