Google Groups unterstützt keine neuen Usenet-Beiträge oder ‑Abos mehr. Bisherige Inhalte sind weiterhin sichtbar.

Passing arguments to gnuplot

6.811 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Yipkei Kwok

ungelesen,
26.10.2009, 17:11:3526.10.09
an
hi,

Is it possible to pass arguments into a GNUPLOT script?

Some folks suggest that shell environment variables may be used for
this purpose. Does anyone have an example, or two?

Thank you!

Hans-Bernhard Bröker

ungelesen,
26.10.2009, 19:06:0026.10.09
an
Yipkei Kwok wrote:

> Is it possible to pass arguments into a GNUPLOT script?

[A side remark: the name of the program is "gnuplot". Not GNUplot, nor
GnuPlot, nor GNUPLOT.]

> Some folks suggest that shell environment variables may be used for
> this purpose. Does anyone have an example, or two?

The time-honoured method is by back-tick substitution:

set variable=`echo $VARIABLE`

This runs the echo command in a sub-shell, and puts the result into a
gnuplot variable.

Yipkei Kwok

ungelesen,
26.10.2009, 22:08:0026.10.09
an
Thank you! It works!!

Just a remark. It should be

set variable `echo $VARIABLE`

And if the parameter is text, it should be

set variable "`echo $VARIABLE` "

On Oct 26, 5:06 pm, Hans-Bernhard Bröker <HBBroe...@t-online.de>
wrote:

Juergen Wieferink

ungelesen,
27.10.2009, 03:00:2027.10.09
an
> Is it possible to pass arguments into a GNUPLOT script?
>
> Some folks suggest that shell environment variables may be used for
> this purpose. Does anyone have an example, or two?

It is probably easier to use the "-e" command line option of the
more recent versions of gnuplot to set a variable:

$ gnuplot -e 'var=value' script.gp


Juergen



Laurianne Gardeux

ungelesen,
27.10.2009, 09:54:0427.10.09
an
Le Mon, 26 Oct 2009 14:11:35 -0700, Yipkei Kwok a écrit :

> Is it possible to pass arguments into a GNUPLOT script?


Sometimes, I use gnuplot in a here-document:

#!/bin/sh
gnuplot <<EOF
[...] "$VARIABLE" [...]
EOF

sfeam

ungelesen,
27.10.2009, 14:03:2527.10.09
an
Yipkei Kwok wrote:

> Thank you! It works!!
>
> Just a remark. It should be
>
> set variable `echo $VARIABLE`
>
> And if the parameter is text, it should be
>
> set variable "`echo $VARIABLE` "
>


Or, if you are doing this inside gnuplot itself:

variable = "`echo $VARIABLE`"

In other words, you don't need to load the value of the environmental
variable as part of the calling script, you can let gnuplot itself
retrieve the current value.

0 neue Nachrichten