From: <pl...@pi...> - 2012-05-16 08:52:17
|
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. This is presumably because you can't reread a pipe but it means plot command is acting differently depending on the data source specified. >>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. 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. > 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. regards, Peter. > Ethan > |