|
From: Juhász P. <pet...@gm...> - 2012-05-20 16:29:37
|
On Sun, 2012-05-20 at 10:36 +0200, pl...@pi... wrote:
> On 05/19/12 17:37, sfeam (Ethan Merritt) wrote:
> > On Saturday, 19 May 2012, pl...@pi... wrote:
> > Speed? Would it solve the problem if you could define a separate
> > datablock in the same input file (separate from the 'plot' command
> > line)?
> >
>
> Yes, maybe defining the data may provide a solution to the case I
> outlined above and may fit in with what Allin is suggesting.
>
> Since the other three input sources produce incompatible results,
> perhaps this one could provide the cached , matrix capabilities that
> Allin was looking for.
>
> Peter.
I haven't followed the discussion, but to this specific point I have a
suggestion:
In Perl there is a special __DATA__ marker that you can use to tell the
interpreter that anything coming after it is data, not code; and there
is a special filehandle to access this data. Example:
#!/usr/bin/perl
while (my $line = <DATA>) {
do_something_with($line);
}
__DATA__
foo
bar
baz
We could adapt this kind of functionality to gnuplot, e.g. like this:
#!gnuplot
plot GPVAL_DATA using 1:2
__DATA__
1 10
2 13
3 17
I'd envision this working by GPVAL_DATA behaving as a normal string
variable most of the time (with the value "__DATA__"), except when it is
used in a plot command, it would magically refer to the inline data
block. The GPVAL prefix would ensure (and signify) that it is a
read-only special variable.
This would
1) provide the data-inlined-in-gnuplot-scripts functionality described
by some in this thread,
2) be familiar to at least some of the users,
3) be relatively easy to implement within the current framework of
gnuplot, without the need of having to (re)write a lot of code or
introduce radically new syntax.
How would this work internally:
if the magical variable (or magical file name) appears in a plot
command, the program would open the script file, scan for the magical
__DATA__ string, and from then on use the usual datafile processing
routines.
I'm not sure about the cases where the commands themselves are streamed
to gnuplot (gnuplot -e 'plot ...'; echo 'plot ...' | gnuplot -; ...),
perhaps this functionality does not make sense in those cases, and
besides, "plot '-'" is already there for those cases.
Péter Juhász
|