Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use text column from data file as points label in gnuplot

Tags:

label

gnuplot

I have a data file consisting of 2 columns with a name and value in it.

foo 0.1
bar 0.2
fff 0.4
bbb 0.7

I want to plot this and annotate the text entry next to the data point.

I tried

plot 'file' using 1:2 with labels 

but it didn't work. I guess the proble is that I have to rely on gnuplot using only the second column for y and equally spacing the x axis.

like image 423
Gert Gottschalk Avatar asked Jan 07 '14 20:01

Gert Gottschalk


1 Answers

You can do something like

plot 'file' using 0:2 title 'title', \
     '' using 0:2:1 with labels offset 0,char 1

This will first plot the data normally, then plot with labels on top, offset up by one character. The 0 column is a dummy column which gives an index to the data--0 for the first data point, 1 for the second, etc.

Another alternative would be to plot using a histogram.

like image 94
andyras Avatar answered Oct 01 '22 20:10

andyras