Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

Do not simplify the design of a program if a way can be found to make it complex and wonderful.


computers / comp.graphics.apps.gnuplot / Re: Variable for data column number?

SubjectAuthor
o Re: Variable for data column number?andreas.buchgraitz

1
Subject: Re: Variable for data column number?
From: andreas....@gmail.com
Newsgroups: comp.graphics.apps.gnuplot
Date: Thu, 30 Jan 2020 16:53 UTC
References: 1 2
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: i2pn2.org!i2pn.org!aioe.org!peer01.am4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.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>
Subject: Re: Variable for data column number?
From: andreas....@gmail.com
Injection-Date: Thu, 30 Jan 2020 16:53:02 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2153
X-Received-Body-CRC: 3273753366
View all headers
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



1
rocksolid light 0.7.2
clearneti2ptor