How to label (x, y) data points in Gnuplot 4.2 with integers

I have a text file with 2 columns of numbers corresponding to (x, y) coordinates.

4 1
4 5
1 1
1 5
2.5 3

      

How do I tell gnuplot to plot these points and mark each point with the appropriate # line? (Please keep in mind, I'm going to apply this to a much larger file with 100 points, so I'm looking for a way to do this automatically, instead of creating a third column of data that matches the line numbers).

+3


source to share


1 answer


You can use a flag with labels

for the plot command. By default, this places the label instead of the point where the point will be. with label

takes a flag offset

(and whatever flag you can pass to set label

) so you can have a label near point. Here's an example script:

#!/usr/bin/env gnuplot

reset

set terminal pngcairo
set output 'test.png'

set xr [0:5]
set yr [0:6]

plot 'data.dat' pt 7, \
     'data.dat' using 1:2:($0+1) with labels offset 1 notitle

      



which produces this output:

enter image description here

+11


source







All Articles