How can I create hypertext-like vectors or arrows that only appear when the user places the mouse on or near the start/end points? For points it looks like this:
indices = "first second"
plot for [id in indices] "a_test.dat" index id u 1:2
replot for [i=1:words(indices)] "a_test.dat" index word( indices, i ) u 1:2:(sprintf("point = (%d, %d)", column(1), column(2))) w labels hypertext point pt 7 ps 2 lc rgb '#ff000000' notitle
File "a_test.dat":
# first
x1 y1
5 1
6 2
9 8
# second
x2 y2
4 5
8 2
2 7



I guess you can mimic a "hypertext arrow" with a
whileloop andpause mouse.For vectors it is better to have start/endpoints in one line, but that is a different topic. I will think about an answer about your other question. Here, for simplicity, it is assumed that you have the start/endpoints already in one line.
the data is plotted once and then you enter a
whileloop (checkhelp while) which you can stop by pressingESC.when button 1 of the mouse is pressed, the data is plotted again, but additionally, the dataline with the minimal distance to the mouse position (i.e. variables
MOUSE_XandMOUSE_Y) is plottedwith vectors. However, it seems you can't useMOUSE_XandMOUSE_Yin a function. So, well, then your have to assign it first to variablesx0andy0.you could probably tune the behaviour of the appearance of the arrow, i.e. whether it disappears after some time or if you move on, etc...)
Script: (tested with gnuplot 5.4.1 and wxt and qt terminals)
Screen capture: (from wxt terminal)
Addition: (keep and remove arrows)
Here is a version where you keep several arrows and you can remove them by clicking again close to their start/endpoint. You can remove all arrows at once if you do a right mouse click (on my system this is
MOUSE_BUTTON==3).arrowIdxscontaining the selected arrows, i.e. line indicesinList()which checks if an index is in the listupdateList()which either adds a new index or removes an index if it was already in the list.I hope you can figure out yourself how the script works in detail. Check
help <keyword>for the following used keywords:sprintf,sum,strstrt,strlen.Script:
Screen capture: (from wxt terminal)