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

Use "column header" (text) as title?

2,684 views
Skip to first unread message

Joerg Hau

unread,
Feb 23, 2004, 12:36:32 PM2/23/04
to
Hi,

How can I retrieve a textual "column header" from a data file, to be
used as title or legend for a graphic?

Let's say file 'data' looks somewhat like this:

# Some text here here
min CmpA CmpB
30 12.5 19.0
40 15.5 15.2
50 17.1 12.2
60 20.0 10.9
70 21.1 9.0

... now I would like to "plot 'data' using 1:2 title $hdr_A, '' using
1:3 title $hdr_B" ... where $hdr_A and $hdr_B should ideally become
"CmpA" and "CmpB", yet automagically retrieved from the 2nd line of
the file.

I need to process a number of files like that, just with many more
columns and with plots involving different files ... hence the need
to be sure that I have the correct dataset on display.

Any ideas (or a suitable shell script ;-) for this purpose?

Cheers & thanks in advance,

- Joerg


--
joerg dot hau at swissonline dot ch * Lausanne, Switzerland
http://homepage.sunrise.ch/mysunrise/joerg.hau/
"All standard disclaimers apply".
remove "nospam." from my address to reply
(this became necessary due to increasing SPAM)

Ethan Merritt

unread,
Feb 23, 2004, 7:30:52 PM2/23/04
to
In article <0ndd1c...@54693.user.dfncis.de>,

Joerg Hau <nospam.j...@swissonline.ch> wrote:
>
>How can I retrieve a textual "column header" from a data file, to be
>used as title or legend for a graphic?
>
>Let's say file 'data' looks somewhat like this:
>
># Some text here here
>min CmpA CmpB
>30 12.5 19.0
>40 15.5 15.2
>50 17.1 12.2
>60 20.0 10.9
>70 21.1 9.0
>
>... now I would like to "plot 'data' using 1:2 title $hdr_A, '' using
>1:3 title $hdr_B" ... where $hdr_A and $hdr_B should ideally become
>"CmpA" and "CmpB", yet automagically retrieved from the 2nd line of
>the file.

If you are willing to build the development version from source, with
a patch applied, then you can get this behaviour easily. See the
sample output and explanation on my web site:
http://www.bmsc.washington.edu/people/merritt/gnuplot/

Using this patched version of gnuplot, the command you would use is

set key autotitle columnhead
plot 'data' using 1:2, '' using 1:3, ...

--
Ethan A Merritt

Joerg Hau

unread,
Feb 24, 2004, 12:53:49 PM2/24/04
to
Hi Ethan,

>>How can I retrieve a textual "column header" from a data file, to be
>>used as title or legend for a graphic?
>

> If you are willing to build the development version

No problem with that :-)

> from source, with a patch applied, then you can get this behaviour
> easily. See the sample output and explanation on my web site:
> http://www.bmsc.washington.edu/people/merritt/gnuplot/
>
> Using this patched version of gnuplot, the command you would use is
>
> set key autotitle columnhead
> plot 'data' using 1:2, '' using 1:3, ...

Aaah ... yes, this works fine with your 'datastrings_3.8j.patch' and
3.8j (which is on my production machine). None of the two patches
worked cleanly with 3.8k1, though ... but I feel that's merely a
matter of some weeks ;-)

Thanks a lot,

0 new messages