Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

History in batch operation

5 views
Skip to first unread message

g1ul10

unread,
Jan 30, 2009, 7:03:04 AM1/30/09
to
Hi all,
AFAIK presently the history function of gnuplot works exclusively in
an interactive session. Moreover if I use

gnuplot -

the input is interactive BUT I do not have history. Why is it so? I
think it would be nice to access history from batch script and,
surely, from an interactive session started with the special '-'
filename.

Looking at the code, I've notice that in plot.c the history set up
part is inside an if (interactive && term != 0){...} condition. Just
moving this part out of the 'if' gave me access to history from batch
(for instance gnuplot -e 'history 10' print the list of last 10
commands). I surely made horrible programming mistakes, BUT I think I
proved that the thing is feasible :-). I work in Linux. The patch
follows.

Giulio


Index: src/plot.c
===================================================================
RCS file: /cvsroot/gnuplot/gnuplot/src/plot.c,v
retrieving revision 1.104
diff -r1.104 plot.c
540d539
< if (interactive && term != 0) { /* not unknown */
569c568
<
---
> if (interactive && term != 0) { /* not unknown */

Hans-Bernhard Bröker

unread,
Jan 31, 2009, 11:24:29 AM1/31/09
to
g1ul10 wrote:
> Hi all,
> AFAIK presently the history function of gnuplot works exclusively in
> an interactive session. Moreover if I use
>
> gnuplot -
>
> the input is interactive BUT I do not have history. Why is it so?

Because gnuplot, in this case, is not in interactive mode of operation.
The '-' command-line argument is meant for use with programs
controlling gnuplot from the outside (after having loaded some scripts
first), not for actual interactive usage by people.

g1ul10

unread,
Feb 3, 2009, 7:03:12 PM2/3/09
to
On Jan 31, 5:24 pm, Hans-Bernhard Bröker <HBBroe...@t-online.de>
wrote:

Thank you for your reply. When I'm doing "data exploration" I like to
be able to plot directly
from the command line. For this purpose I wrote a little shell
function 'gbplot' that I use,
for example, in this way

program_that_generates_data | gbplot -i plot u 0:1 w lp

the script opens a terminal controlling a gnuplot session, displays
the plot, and enters
and interactive session in whcih I can change axes scale or set log or
whatever seems
interesting to do. The function code can be found here (it's a zsh
function; does not work
in bash) http://giulio.bottazzi.googlepages.com/zshrc This method is
more practical than
first opening a gnuplot session and then use

plot "< program_that_generates_data"

Essentially the script works by building two suitably defined
temporary files 'CMDFILE' and
'ENDFILE' and starts gnuplot with

gnuplot $CMDFILE - $ENDFILE

Everything works nicely (because gnuplot is a fantastic program) APART
being able to access
previous history. I miss this feature because being data exploration a
back and forth exercise, I
often find myself re-typing the same lines.

Sorry for the long post. I think it was useful to clarify why I think
this feature could be of some use.

Best,
G.

P.S.: By the way, gnuplot's help says:

To launch an interactive session after an initialization file
"header" and
followed by another command file "trailer":
gnuplot header - trailer

0 new messages