8

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.

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
Gert Gottschalk
  • 1,658
  • 3
  • 25
  • 37
  • Related: https://superuser.com/questions/67228/how-to-plot-dot-labeled-data Coordinates instead: https://stackoverflow.com/questions/23177716/in-gnuplot-how-to-label-each-point-in-the-plot-with-its-coordinates String label formatting: https://stackoverflow.com/questions/34514279/using-sprintf-to-print-string-value On hover: https://stackoverflow.com/questions/13269811/how-to-show-a-label-from-a-third-data-column-on-mouseover-hover-in-a-gnuplot-s – Ciro Santilli OurBigBook.com Apr 28 '19 at 08:23

1 Answers1

12

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.

andyras
  • 15,542
  • 6
  • 55
  • 77
  • 2
    For the `labels` plotting style you can specify an `offset`: `plot 'file' using 0:2 with labels offset 0,char 1 title 'title'`. The advantage of this is, that you can give the offset in `character` units. – Christoph Jan 08 '14 at 12:37