Menu

#546 Mouse coordinates in multiplots

None
open
nobody
5
2024-03-10
2022-10-15
theozh
No

In an interactive terminal, e.g. like wxt or qt, in a multiplot environment the mouse coordinates in the status bar are displayed from the last plot in the multiplot independent whether you are moving the mouse over another (sub)plot. This is confusing, not very helpful and not at all meaningful.

It would be very helpful if you could quickly read values out of any plot in a multiplot environment. Of course, if you have overlapping plots, the value of the later plot (on top) should be taken.

Although, you can realize this more or less in a lengthy gnuplot (>=5.4.0) script, but I would very much appreciate it if this could be integrated into gnuplot itself.
For a script attempt check: https://stackoverflow.com/q/72445424/7295599

Discussion

  • Ethan Merritt

    Ethan Merritt - 2022-10-15
    • Group: -->
     
  • Ethan Merritt

    Ethan Merritt - 2022-10-15

    There are two limitations to the way gnuplot was designed that come up over and over.

    One of the them is "please allow mousing in multiplots", i.e. this one. See for example request #35 going back 20 years, and related oldies #344 and #505.

    The other one is "please allow the independent coordinate to be y rather than x, so that any plot can be laid out either horizontally or vertically".

    For both of these everyone including the developers agree it would be nice to have. Unfortunately that just isn't the way gnuplot was designed. It's not something we can paste on afterwards as an extra feature. In the case of mousing multiplots, it would be possible to modify some individual terminals to handle it. The canvas and svg terminals already do this, sort of, since if you position several plots on the same web page the browser can track their mouse coordinates separately because a separate javascript module is created for each plot. That's why you can zoom the sample plots in the svg online demo collection. But the necessary information about page layout, axis limits, scaling, is not kept in the core gnuplot program code so it is simply not there to be used for mousing anything but the currently active plot.

    Edit However a more limited objective might be possible. If you limit the support to simply reporting mouse coordinates (no zoom, pan, rotation, annotation, etc) then I think it would be possible to add a new data structure to the core code describing the most recent multiplot. It would track which portion of the screen corresponded to each component plot and what the axis ranges and scaling were for that plot.

    Since improvement or addition to individual terminal drivers is one of the best ways to dip your toes into gnuplot development, this would be a great project for anyone wanting to try their hand at contributing to the project. Pick one of the interactive terminals and add whatever extra data structures are needed to maintain state information for previous plots. I am 99% sure this could be done for qt, x11, and wxt. I am less sure about windows. A slightly more ambitious project would be to tackle the Mac-specific aquaterm terminal. It doesn't currently support mousing at all, but I know of no reason it couldn't. Or someone could tackle limited mouse coordinate reporting for the most recent multiplot as mentioned above.

     

    Last edit: Ethan Merritt 2022-10-15
  • theozh

    theozh - 2022-10-16

    Sorry, although I did a short check about "multiplot" and "mouse" I did not find the "historic" feature request #35.
    Thank you for the background information.

    Yes, I was only hoping/asking for mouse coordinates in the original multiplot, i.e. no zooming, etc.
    For each plot the necessary values are stored in the GPVAL_ variables after plotting,
    however, with one exception: there is no GPVAL_ variable if logscale was set or or unset.

    Either new variables are required, e.g. GPVAL_X_LOG_SET and GPVAL_Y_LOG_SET which are 0 or 1, or alternatively, GPVAL_X_LOG and GPVAL_Y_LOG need to be set back to 10.0 as soon as you unset logscale x and unset logscale x which is currently not the case.

    Of course, these GPVAL_ variables are overwritten for the next (multi)plot.
    So, you need to memorize them. And that's what the script in https://stackoverflow.com/q/72445424/7295599 is doing.

    Together with the experimental feature set mouse mouseformat function string_valued_function(x, y) you can display the "right" coordinates of a (sub)multiplot.

    If this could be realized in gnuplot directly, this would be great!
    Of course, I cannot estimate all the dependencies and necessary changes in the source code.

     

    Last edit: theozh 2022-10-16
    • Ethan Merritt

      Ethan Merritt - 2022-10-16

      The problem with that approach, at least without an additional layer or three of bookkeeping, is that there is no obvious way of controlling how long this customized mouse reporting is valid for or what plot[s] it applies to. That is an issue whether implemented as a script or as a built-in tracking mechanism.

      Consider what happens when the example multiplot in your stackoverflow script is followed by set term wxt 2; plot something-else. Now there are two plots on the screen, the original multiplot and the subsequent plot in a new window. Neither one will report correct mouse coordinates. The previous mouse settings clearly do not apply to the new plot, and the bookkeeping for mousing the original multiplot is no longer sufficient either. I'm not entirely certain what happens here in the case of the wxt terminal. For qt and other terminals with an 'outboard' terminal driver the mousing is taken over by separate terminal-specific code running in a different process (gnuplot_qt or gnuplot_x11, etc) so the scripted custom mousing routines defined for the main process are not available. It didn't work for wxt either when I tested it but the precise reason it fails must be different.

      I think that in order for this to work, all the relevant plot limits, scaling, ranges, etc need to be stored together with the plot commands themselves as part of the plot structure. Then this information is available to whatever process (inboard/outboard gnuplot driver, web browser, etc) is used to display the composite multiplot. That is already done for individual plots output from the canvas and svg terminals, since their mousing is mediated by external javascript code rather than by the gnuplot core code. These terminals don't currently handle wrapping multiple separate plots into one multiplot but I imagine it could be extended if necessary. Note that you don't really need multiplot for these terminals since you can display multiple individual plots on the some output display page even without it.

       
  • theozh

    theozh - 2022-10-16

    Oops, right. I haven't thought about multiple terminal windows. Yes, I could possibly display several measurements/graphs in multiple, e.g. wxt windows. However, that's what I (in my case) actually want to avoid and therefore I am using multiplot in a single terminal window.

     
  • Ethan Merritt

    Ethan Merritt - 2024-03-10

    Update

    Version 6 now supports some mousing operations in a multiplot, including coordinate readout of the most recently plotted component. That's one step closer to being able to retrieve coordinate information for all multiplot components.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.