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


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

Re: Variable for data column number?

X-Received by 2002:a05:620a:81c:: with SMTP id s28mr6225683qks.11.1580403182911; Thu, 30 Jan 2020 08:53:02 -0800 (PST)
X-Received by 2002:aca:f587:: with SMTP id t129mr1815561oih.143.1580403182622; Thu, 30 Jan 2020 08:53:02 -0800 (PST)
Path csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups comp.graphics.apps.gnuplot
Date Thu, 30 Jan 2020 08:53:02 -0800 (PST)
In-Reply-To <fv712b$s4s$1@sagnix.uni-muenster.de>
Complaints-To groups-abuse@google.com
Injection-Info google-groups.googlegroups.com; posting-host=185.45.22.140; posting-account=Y3KToAoAAADDcG4FrmExng-EBKS9SMpt
NNTP-Posting-Host 185.45.22.140
References <67o8brF2n392sU1@mid.individual.net> <fv712b$s4s$1@sagnix.uni-muenster.de>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <6ad1397d-c998-4a1e-9c25-3dbc0757456c@googlegroups.com> (permalink)
Subject Re: Variable for data column number?
From andreas.buchgraitz@gmail.com
Injection-Date Thu, 30 Jan 2020 16:53:02 +0000
Content-Type text/plain; charset="UTF-8"
Lines 32
Xref csiph.com comp.graphics.apps.gnuplot:4287

Show key headers only | View raw


tirsdag den 29. april 2008 kl. 13.33.31 UTC+2 skrev Juergen Wieferink:
> Ingo Thies wrote:
> > c1=1;c2=2
> > plot 'file' using c1:c2
> > 
> > But is it also possible to use variables for column numbers as a
> > function argument? "$c1" or similar don't work. For now, I can only do
> > this by replacing the column specifier in all the lines by
> > search&replace, but a global switch would be much more convenient.
> 
> This could be done using macros "help macro", but the clean way is
> via the column() function (help column) [untested]:
> 
> c1=1;c2=2
> plot 'file' using (column(c1)):(column(c2))
> 
> 
> Juergen

Thanks, This works amazing if one wants to do math on each entry in a column, but directly in a bash script, for example subtracting some number from every entry: 

#!/bin/bash

gnuplot <<-EOF

set terminal pdf
set output "test.pdf"
plot "data.dat" u 1:(column(2)-2.63E-02) with lines

EOF

evince test.pdf

Back to comp.graphics.apps.gnuplot | Previous | Next | Find similar


Thread

Re: Variable for data column number? andreas.buchgraitz@gmail.com - 2020-01-30 08:53 -0800

csiph-web