21

I have a table like this:

A B C D E F G H I 
10 23998 16755 27656 17659 19708 20328 19377 18925
20 37298 33368 53936 41421 44548 40756 40985 37294

I use this command to plot

plot "C:/file.txt" using 1:2 with lines smooth bezier, "C:/file.txt" using 1:3 with lines smooth bezier, ...

However, all the labels come out as the file name. Is it possible for gnuplot to read the first row and label the lines accordingly?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
Verhogen
  • 27,221
  • 34
  • 90
  • 109
  • I suppose this is a cmd.exe command line parsing issue rather than a gnuplot issue. Can you line out the desired command line syntax for those who have no knowledge of gnuplot? – Tomalak Apr 21 '09 at 17:50
  • Hmm.. I'm not sure what you mean. All this happens purely in gnuplot. – Verhogen Apr 21 '09 at 19:51
  • @Tomalak: this is done in the gnuplot shell, it has nothing to do with cmd.exe command-line parsing. (The same thing happens on Linux) – David Z Apr 21 '09 at 20:31
  • For those that want to name axis labels in a scatter plot: https://stackoverflow.com/questions/16089301/how-do-i-set-axis-label-with-column-header-in-gnuplot – Ciro Santilli OurBigBook.com Apr 27 '19 at 16:44

5 Answers5

34
set key autotitle columnhead
Svante
  • 50,694
  • 11
  • 78
  • 122
4
plot for [n=2:12] 'vv.csv' u 1:(column(n)) w lines title columnhead(n)

n starts from 2 to skip the header.

beliz
  • 402
  • 1
  • 5
  • 25
Elden Crom
  • 71
  • 2
2

I checked the documentation and I don't see a way to do it automatically, but you can manually set a title with

plot "file.txt" using 1:2 title "A" with lines smooth bezier ...
David Z
  • 128,184
  • 27
  • 255
  • 279
  • if the data format is ecactly the way you described in your question I would use this manual aproach as well – Peter S Oct 19 '15 at 13:06
-1

I once wrote a script to plot FM radio station frequencies along an axis from 87MHz to 108MHz, using the names of each radio station as vertical labels. This was not a pure gnuplot solution, the input file is processed with perl with make, but I suggest you have a look at it and see if you can use something like that.

hlovdal
  • 26,565
  • 10
  • 94
  • 165
-1

You could also use a gnuplot toolkit such as this one for Python if you want have a lot of data to plot and you want to automate the extraction of the titles.

moinudin
  • 134,091
  • 45
  • 190
  • 216