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

萝らか妹 提交于 2019-12-01 17:53:00

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.

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!