Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show a label from a third data column on mouseover / hover in a Gnuplot scatter plot?

I have a gnuplot data file:

Requested_width,Requested_depth,Requested_word,Name,N,M,Cycle_time,Clk2Q,Area,Total_Area
24,512,24,R1F512X24M8P24,1,1,1.9820,,7446.102,7446
24,512,24,R1F512X24M4P24,1,1,1.9937,,6757.0596,6757
....

I want to scatter plot columns 7 and 9 (this I can do!), then I want the name in column 4 to appear when I mouse over a data point. I think it will be too cluttered to have all labels present at all times.

like image 722
user1806063 Avatar asked Nov 07 '12 12:11

user1806063


2 Answers

This is completely possible in gnuplot4.7 (the current development branch), but not in previous versions -- The following works just fine when input from an interactive prompt:

set term wxt
set termoption enhanced
set datafile sep ','
plot 'test.dat' u 7:9:4 w labels hypertext point pt 7

If you put it in a script, you need to invoke gnuplot as gnuplot -persist script.gp.

like image 81
mgilson Avatar answered Sep 21 '22 02:09

mgilson


Just use hypertext and specify the correct terminal, you can make hypertext works.

1) You need to use hypertext as describe in GNUPlot manual link, page 122:

set label at 0,0 "Plot origin" hypertext point pt 1
plot 'data' using 1:2:0 with labels hypertext point pt 7 \
title 'mouse over point to see its order in data set'

2) There are currently 3 terms that support hypertext: canvas(HTML5), svg, and wxt. Let's take canvas as an example, on page 182 of the manual, there is an example show you how to use canvas:

set term canvas name 'fishplot'
set output 'fishplot.js'

And a minimal HTML file:

<html>
<head>
  <script src="canvastext.js"></script>
  <script src="gnuplot_common.js"></script>
</head>
<body onload="fishplot();">
  <script src="fishplot.js"></script>
  <canvas id="fishplot" width=600 height=400>
    <div id="err_msg">No support for HTML 5 canvas element</div>
  </canvas>
</body>
</html>
like image 22
zhanxw Avatar answered Sep 22 '22 02:09

zhanxw