1
votes

I have the below gnuplot script, I'm trying to display the third column when the mouse hover over a point of the plot.

set title "Cloud"
set xlabel "Date"
set ylabel "Number"
filename ='data.dat'
stats filename using 4 nooutput

set xdata time
set timefmt '%Y-%m-%d'
set format x '%Y'


rand_x(x) = x + 60*60*24*7 * (rand(0) - 0.5)
rand_y(y) = y + (rand(0) - 0.5)
set xrange [ "1995-01-19":"2013-12-12" ]
plot for [i=0:int(STATS_max)-1] filename \
using (rand_x(timecolumn(1))):(i < $4 ? rand_y($2) : 1/0):3 pointtype 7 linecolor  palette notitle
u 0:1:2 with labels hypertext point pt 7 ps var lc rgb "#ffee99"

And the data file looks like below:

1999-01-19  21  0   1
2009-07-01  0   1   1
2008-08-20  2   1   1
2008-12-18  1   1   1
2004-05-12  4   1   1
2009-07-29  2   1   1
2008-08-07  0   1   1
2006-03-08  1   1   1
2004-08-31  9   1   1
2001-03-27  12  1   1
2009-08-19  0   1   1
2010-07-14  2   1   1
2009-06-24  0   1   1
2009-11-11  0   1   1
2010-10-13  0   1   1
2012-02-22  0   1   1
2011-05-11  0   1   1
2011-03-03  0   1   1
2011-09-21  0   1   1
2011-12-20  0   1   1
2011-10-05  0   1   1
2012-05-03  0   1   1
2011-10-05  0   2   1
2013-01-09  0   2   1
2011-06-03  0   2   1

So can you please tell me what's wrong with my script? Thanks.

1

1 Answers

1
votes

First a remark for the readers: hypertext works only with the 4.7 development version.

To your problem: For plotting the labels, you must also use the same x and y columns 1 and 2 (you use 0 and 1). And you need the third column for the labels and a fourth one for the ps var. So your plot part for the labels is:

plot for [i=0:int(STATS_max)-1] filename \
using (rand_x(timecolumn(1))):(i < $4 ? rand_y($2) : 1/0):3 pointtype 7 linecolor  palette notitle,\
'' u 1:2:3:3 with labels hypertext point pt 7 ps var lc rgb "#ffee99"