I usually draw plots using gnuplot. See Plot a spiral with gnuplot for an educational example.

Most interactive terminals (rendering frontend drivers) of gnuplot support using the mouse. These include the wxt and x11 terminals.

If you make a plot on such a terminal, then hover the mouse over the plot window, the coordinates of the hovered points will show up printed in the corner of the plot window. If you click the mouse, gnuplot stores the coordinates in the variables MOUSE_X and MOUSE_Y, which you can query with the print statement of gnuplot. I believe you can even bind a callback function gnuplot will execute on mouse clicks, see the gnuplot manual for details.

There is one limitation of mouse handling that is worth noting. If you are using a multiplot (multiple independent plot areas side by side in a window), then you can get the coordinates corresponding to the last plot area only.


In reply to Re: Hover over scatter plot by ambrus
in thread Hover over scatter plot by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.