Reputation: 1228
I am doing a multiplot in gnuplot. I want to pick the labels for the points from certain columns. For example, say the data file is:
year temp label1 year humidity label2
1990 30 hot 1991 100 wet
1992 25 warm 1992 83 dry
I want to plot column 2 (temp) versus column 1 (year) using column 3 (label1) as label for the points and on the same graph plot column 5 (humidity) versus column 4 (year) using column 6 (label2) as label. Is this possible?
plot 'weather.dat' using 1:2 with points with labels, '' using 4:5 with points with labels
Upvotes: 3
Views: 4640
Reputation: 7590
Use the labels style. This style expects to receive the x and y coordinates along with the label column.
For your data, and the first part of the plot, we can do
plot 'weather.data' using 1:2 with points, '' using 1:2:3 with labels
If we wish to add a little spacing, we can adjust the label y coordinate. For example, moving it up by 1 unit with
plot 'weather.data' using 1:2 with points, '' using 1:($2+1):3 with labels
For this plot, in order to make sure that everything fit completely inside, I manually set the xrange to [1989:1993] and the yrange to [20:35].
A similar approach works with your other columns of data, which can, of course, be combined with this as normal (although with the massively different y range, probably should be done on it's own plot, or using a secondary axis).
See help labels
for more information.
Upvotes: 2