Question

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?

Was it helpful?

Solution

set key autotitle columnhead

OTHER TIPS

plot for [n=2:12] 'vv.csv' u 1:(column(n)) w lines title columnhead(n)

I didn't want to plot the first column of data hence n=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 ...

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top