|
From: Daniel J S. <dan...@ie...> - 2012-05-16 16:36:12
|
On 05/16/2012 02:35 AM, pl...@pi... wrote: > On 05/16/12 06:56, sfeam (Ethan Merritt) wrote: >> On Monday, 14 May 2012, su...@pi... wrote: >>> On 05/14/12 18:27, Ethan A Merritt wrote: >>>>>> So could another flag like plot '--' be used to indicate rereading of >>>>>> the inline data rather than continuing at the next block of inline data ? >>>> This wouldn't work in the general case - you can't reread from a pipe. >>> >>> hmm. I hadn't thought of "inline" data actually being a pipe. Good point. >>> >>> perhaps that could be accepted as a limitation on reading from pipes. >>> It would not reduce the functionality that is already available to pipes. >> >> Up till now, the following have all been equivalent: >> gnuplot file.in >> cat file.in | gnuplot >> cat file.in | gnuplot - >> gnuplot -e 'load file.in' >> >> I think it would be a bad idea to introduce new syntax that breaks >> this equivalence. > > I agree, I like that sort of symmetry. > > Part of the problem here is that plot '-' does not work in quite the > same way as plot datafile > > plot '-','-' plots two consecutive segments from stdin whereas plot > datafile , datafile rereads the file and plots the same thing twice. I see the point. > This is presumably because you can't reread a pipe but it means plot > command is acting differently depending on the data source specified. It wouldn't be difficult to program this so that the same data is used multiple times. There has always been incentive to store the original data for redrawing purposes other than this, and I think I had written a patch some time ago that does that. However, this isn't as different as you think. I would guess that if "datafile" were changed at an instant between when gnuplot does the two plots, the two plots would look different. The analogy is typing the same thing at the keyboard or pipe when using '-'. Perhaps there should be a mode switch, "use the same data" or "don't reread". But I'm not sure how crucial that is. > >>Consider: > >> plot '-' using 1:2, '' using 3:4, '' using 99:100 > >> The first plot uses only columns 1 and 2; these values are stored > >> internally and could be used again without rereading. That's what the > >> "refresh" command does. But the 2nd and 3rd plots use data values > from > >> columns we didn't use the first time and hence didn't keep. > >> So those values can only be recovered by rereading. > > > Since this is all in one plot command , couldn't the whole line be > > parsed to find all the columns to be required by all the using clauses? > > > > In fact isn't this already done? Are you implying that > > > > plot datafile using 1:2, '' using 3:4, '' using 99:100 > > > > actually reads the data file three times looking at different columns :? > > >> Yes. > > So if I get this, > > gnuplot> plot datafile using 1:2, '' using 3:4 > > opens and reads same lines of the file twice. Filling two sets of slots > > > gnuplot> plot '-' using 1:2, '' using 3:4 > > reads consecutively from stdin , twice. Filling two sets of slots > > > It would be more efficient if the first version parsed the whole line to > find all required columns and did one read. I do plots with 5 or 6 > lines, this could be a useful improvement. This creates some logistical problems of storing the data or accessing the data at different times between different sections of code. It is all dependent upon the way gnuplot is programmed internally. When gnuplot started long ago, that was sort of the paradigm; linear run the data through various steps. I did write a patch at some point that stores the unprocessed data and can feed it through a second, third, etc. time. That is still the same paradigm so not much change to gnuplots innards (requires lots of memory so it would be nice to deactivate such a feature). > Then the suggested '--' could work with no extra effort. > gnuplot> plot '--' using 1:2, '' using 3:4 > > > The asymmetrical behaviour of the existing plot '-' would still need a > different code path. Have to think about this, because again it isn't clear that '-' and 'datafile' are currently acting differently. >> If the previous work-around I suggested is too >> long-winded, requiring a "print" and matching quotes on each line, >> how about introducing an idea from perl: >> >> set print 'tempfile.dat' >> print<< EOF >> 1st line of data >> 2nd line of data >> 3rd line of data >> EOF >> > > Yes , I was looking for something like that yesterday. I think that > would be a useful addition in a number of situations. > > However, rewriting all the data in the current file to another > superfluous copy just to get around the syntax seems a bit clunky. Yes, but that is the nature of gnuplot going back to the beginning. What you are suggesting is a pretty fundamental change. Dan |