7
3
I'd like to turn a file like:
Name X Y
a 1 2
b 4 1
s 3 3
in a X-Y graphic with the X-Y dots labeled with Name.
How can I do it? I think this can be done with gnuplot, but I wasn't able to do it yet.
7
3
I'd like to turn a file like:
Name X Y
a 1 2
b 4 1
s 3 3
in a X-Y graphic with the X-Y dots labeled with Name.
How can I do it? I think this can be done with gnuplot, but I wasn't able to do it yet.
6
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)
If not available, the error looks like "Not enough columns for this style"? I guess it's not available here where I am :( – KcFnMi – 2017-06-17T22:18:15.450
+1 nice avoidance of a separate label file. I've always done it that way and didn't think there was any other way. – DaveParillo – 2009-11-08T21:06:42.100
3FYI: If this example doesn't work for someone - the labels
style is available only if gnuplot is built with configuration option --enable-datastrings – DaveParillo – 2009-11-08T21:16:02.110
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.
related: https://stackoverflow.com/questions/20981589/use-text-column-from-data-file-as-points-label-in-gnuplot
– Ciro Santilli 新疆改造中心法轮功六四事件 – 2019-04-28T08:06:01.857I'm fairly certain gnuplot can do it too, but I'm no master, sorry. :( – Paul Nathan – 2009-11-07T18:02:31.763