Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #716

i=2; p 'data' u 1:($i)

Newsgroups comp.graphics.apps.gnuplot
From Khanh-Dang <khanh-dang@w.fr.invalid>
Subject i=2; p 'data' u 1:($i)
Organization :noitazinagrO
Message-ID <slrnjdcdfb.tlt.khanh-dang@parvati.pmmh.espci.fr> (permalink)
Date 2011-11-30 13:55 +0000

Show all headers | View raw


Hello,

Sorry for the subject, it was the most meaningful string I was able to
find.  As you might have guessed, I would like to plot a data file by
using a syntax like:

    f(x) = x**1.5
    i=2
    p 'datafile' u 1:(f($i))

In the last command, (f($i)) should be equivalent to (f($2)), i.e. the
string "i" in "$i" should be substituted with the content of the
corresponding variable.  Of course, the variable must be defined; if
not, gnuplot should not execute the command and should print a
meaningful error message.

I would find this feature mostly useful when using gnuplot
interactively.  I usually plot several data files, and it would be great
to have the possibility to do for example:

    f(x) = x**1.5
    i=2;
    p 'datafile1' u 1:(f($i)), 'datafile2' u 1:(f($i))

Then, if I want to plot 1:(f($3)), I would just have to do a "i=3",
instead of reediting the whole command and replacing by hand all the
"$2" by "$3".

Can gnuplot actually do this kind of substitution?  If not, and assuming
that this new feature is compatible with the syntax grammar of the
current version gnuplot (is it?), how difficult is it to implement it?
I ask because I can eventually work on it.

Thank you for reading,

Khanh-Dang

Back to comp.graphics.apps.gnuplot | Previous | NextNext in thread | Find similar


Thread

i=2; p 'data' u 1:($i) Khanh-Dang <khanh-dang@w.fr.invalid> - 2011-11-30 13:55 +0000
  Re: i=2; p 'data' u 1:($i) ab <ab.3942@googlemail.com> - 2011-11-30 06:09 -0800
    Re: i=2; p 'data' u 1:($i) Khanh-Dang <khanh-dang@w.fr.invalid> - 2011-11-30 15:31 +0000

csiph-web