How to plot dot labeled data?

Solution 1:

You can put labels at a specified offset from the points using the following gnuplot command:

echo "plot 'file.dat' using 2:3 pt 2 notitle, '' using 2:3:1 with labels offset 0.5,0.5 notitle;" | gnuplot -persist

NB: works only if gnuplot has been compiled with --enable-datastrings (thanks to DaveParillo for the clarification)

Solution 2:

Gnu plot can't do this alone. I doesn't know what to do with the text. If your data exists in a file named file.dat, then:

perl -ane 'print "set label \"($F[0])\" at $F[1],$F[2]\n"' file.dat > label.plt

will produce a label file you can use in gnuplot. You can then produce a (very basic) plot like this:

gnuplot> load "label.plt"
gnuplot> plot 'file.dat' u 2:3

You can mess around with the label offset if you want. For example,

"set label \"($F[0])\" at $F[1]+0.05,$F[2]+0.05\n"' 

moves the labels out a bit, so that they are not right up against your points.