patchGNU Octave - Patches: patch #9280, Add data cursor functionality in...

 
 

patch #9280: Add data cursor functionality in plots

Submitter:  Roland Baudin <roland65>
Submitted:  Mon 06 Mar 2017 08:56:05 AM UTC
   
 
Category:  Core : new feature Priority:  5 - Normal
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 31 Dec 2023 10:23:45 PM UTC, comment #18: 

This refers to just a patch that hasn't been accepted, hasn't been worked on for quite a while, and AFAIR doesn't apply cleanly anymore.

That said the added functionality is very nice and welcome.

Philip Nienhuis <philipnienhuis>
Group Member
Sun 31 Dec 2023 07:00:46 PM UTC, comment #17: 

Hi,

Where can I find the functionality mentioned here in 8.2.0?  Thanks.

Liang Tang <lt1234>
Sat 12 Sep 2020 06:17:06 PM UTC, comment #16: 

Good stuff! I have some comments and questions:

1. datacursor cannot be moved/adjusted/deleted after initial placement? Would like to be able to unstick and move and delete. Need this fairly badly.

2. there is no way to add a user-defined function to display data values in a different format, e.g. as YYYY-MM-DD using datestr()? Note that <nrjank> comment1 below hints at some such matlab functionality that would be desirable, namely the UpdateFcn — Callback function that formats data tip text. Really need this.

For a concrete example off how matlab can do this, see https://www.mathworks.com/matlabcentral/answers/117068-how-can-i-view-the-formatted-date-string-datestr-while-using-date-cursor-for-a-plot-containing-date

3. datacursor does not react to a changing zoom level, but rather stays in a fixed position on the canvas? This is maybe a bit tricky to fix, but "would be nice".

4. Could we get just a few lines of a manual to explain what each mouse button is supposed to do, etc)?


Thanks, datacursor is a very useful addition to Octave.

Reik Red <reikred>
Tue 09 Jun 2020 12:35:22 PM UTC, comment #15: 

I have the datacursor stuff in my mxe crossbuilds, the few times I could use it it work fine.

However, they influence some BIST tests of core Octave functions:

  • hold.m
  • ishold.m
  • publish.m


and maybe (these started FAIL-ing after I added datacursor) also

  • copyobj.m
  • hgsave.m


so a final cset needs to also need fixes for these tests.

Philip Nienhuis <philipnienhuis>
Group Member
Sun 10 May 2020 07:40:01 AM UTC, comment #14: 

"patch", "surface" and "image" objects also have x/y/zdata that could be displayed in the data tooltip. Basically anything that is displayed in axes must have some kind of x/y/zdata information. That is why I asked whether it might make sense to use the "axes" function instead of changing a whole lot of plotting functions.
I don't think any interpolation should be done.

Like I also wrote, it wouldn't be necessary to support all of these graphics objects in a first version. But support for them can be added in the future.

For 3d scenes, I think that it would be possible to find the point closest to the line of sight given by the two coordinates in the axes property "currentpoint". But that also would only be a "nice-to-have" for a first version.

Another point: It might be good to have a solid background for the annotation to make it easier to read the numbers in busy graphs.

Markus Mützel <mmuetzel>
Group administrator
Sat 09 May 2020 11:01:58 PM UTC, comment #13: 

I don't know anything about the underlying function, but if it answers some questions about what it should do, I could try some Matlab compatibility tests if someone can lay out some specific procedures

Nicholas Jankowski <nrjank>
Group Member
Sat 09 May 2020 09:27:40 PM UTC, comment #12: 

I think linking it to axes is probably not a good idea - think of patches, what does the cursor need to point to? interpolate in 2D? (or 3D?)
Would linking through __plt__.m not catch most "line" and "point" occurrences?

A datacursor for 3D is challenging - any position along a line perpendicular to the projection on the canvas is a valid coordinate point, what should datacursor return in case of stacked surfaces or solid 3D objects? But maybe there is a clever way to do it. If it operates on 3D polylines or "wrinkled' 3D polygons it could work.

Philip Nienhuis <philipnienhuis>
Group Member
Sat 09 May 2020 09:41:49 AM UTC, comment #11: 

Thanks for creating the patch.

I still haven't checked if the function actually works. But anyway some comments:

  • The copyright blocks seem to follow a previous style. (No surprise given the report is over 3 years old.)
  • "Author", "Created", "Modified by" and similar lines should be removed.
  • The patch should probably be attributed to Pantxo or Roland Baudin because they seem to have done most of the work.
  • Would it make sense to call "__datacursor_menu__" in the "axes.m" function instead of in various other graphics functions?
  • Does this work for 3D scenes?
  • Would it be possible to add support for other graphics objects than "line"? (Although supporting only "line" objects is probably good enough for a first step.)
Markus Mützel <mmuetzel>
Group administrator
Thu 30 Apr 2020 06:42:51 PM UTC, comment #10: 

It's quite a "rough" patch, glancing through it :-) But the good thing is, now the line numbers match.

As I wrote in comment #6, the only relevant stanzas in the v3 patch were the two new functions, and adding a call to  __datacursor_menu__ in the end of scripts/plot/draw/private/__plt__.m and apparently _stem_.m. and scripts/plot/draw/stairs.m.

I've manually weeded out the unneeded hunks and attached the cleaned up patch. Perhaps hunk #3 is troublesome but it's easy to see what needs to be done after trying to apply it.

Still I'm unsure if the call to __datacursor_menu__ needs to be entered into more plot functions. Maybe also 3D plot functions.


(file #48977)

Philip Nienhuis <philipnienhuis>
Group Member
Wed 29 Apr 2020 09:37:26 PM UTC, comment #9: 

here's a quick bad patch based on the V3 files. I just overwrote the existing files with the zipped file #40676.  It's quite a bit out of date, and probably needs to be stepped through line by line to update it for the current codebase. But, there it is.

as an hg neophyte, is there a convenient way to apply files to the codebase, as opposed to a patch, and do a diff/compare?

(file #48968)

Nicholas Jankowski <nrjank>
Group Member
Fri 24 Apr 2020 05:47:57 PM UTC, comment #8: 

It might be a personal preference. But I find it much easier to see what changed when working with patches. They don't have to be perfect...

Markus Mützel <mmuetzel>
Group administrator
Fri 24 Apr 2020 05:13:18 PM UTC, comment #7: 

i guess the comment #4 thought was that it would be easier for multiple people to work on, assess, etc., if a quick source patch was made.  is it better to keep it as a series of attached  m-files? Or do people prefer to share and increment patches?

Nicholas Jankowski <nrjank>
Group Member
Fri 24 Apr 2020 04:18:36 PM UTC, comment #6: 

Before turning it into a cset it seems some more work needs to be done.

Essentially the patch boils down to:

  • adding __datacursor_menu__.m and __datacursor__.m into scripts/plot/draw/private/
  • adding a call to __datacursor_menu__ in the end of scripts/plot/draw/private/__plt__.m and apparently __stem__.m

but maybe it needs to be called in other basic plotting functions as well; that has to be sorted out.

If the plot window is closed, do the listeners installed by the new functions have to be deleted explicitly?

It has to be sorted out why, after requesting the cursor XY data, hitting the Enter key is needed to get the variable into scope.

The prefix for Windows paths is made in mxe-octave no need to explicitly add it.

A personal not: compared to Panxto's original .m files
(https://octave.1599824.n4.nabble.com/Data-cursor-in-Octave-tp4681801p4681843.html)
this v3 patch has just black annotations in quite a big font (Panxto's had another color for each new annotation and in smaller font, both of which I liked better)

Philip Nienhuis <philipnienhuis>
Group Member
Fri 24 Apr 2020 01:45:19 PM UTC, comment #5: 

Note that the prefix for the windows path below is missing the mingw64 folder.  I.e., the files should wind up in:

C:\Octave\octave-5.2.0-w64\mingw64\share\octave\5.2.0\m\plot\draw


In the source tree, I guess they should live in: /scripts/plot/draw

Nicholas Jankowski <nrjank>
Group Member
Fri 24 Apr 2020 07:15:01 AM UTC, comment #4: 

Could you provide a Mercurial patch against the current default branch with these changes?
The currently provided format makes it difficult to review the change.

Markus Mützel <mmuetzel>
Group administrator
Fri 12 May 2017 02:46:42 PM UTC, comment #3: 

Here is another update that fixes a bug when using the data cursor and several figures.

To install the new version, download the datacursor-v3.zip archive and copy it to your <prefix>/share/octave/<version> directory (<prefix> is /usr for Linux, c:\octave for Windows and <version> is Octave version number) and unzip it.


(file #40676)

Roland Baudin <roland65>
Fri 05 May 2017 01:44:02 PM UTC, comment #2: 

I've updated the data cursor menu and function:
- the issue with the right click mouse button is fixed
- the Data menu now also appears in stem and stairs plots

To install the new version, download the datacursor-v2.zip archive and copy it to your <prefix>/share/octave/<version> directory (<prefix> is /usr for Linux, c:\octave for Windows and <version> is Octave version number) and unzip it.





(file #40594)

Roland Baudin <roland65>
Mon 06 Mar 2017 09:16:50 PM UTC, comment #1: 

just adding to discussion on Octave implementation, there are a couple Matlab functions relating to this feature that are currently unimplemented in Octave:

datacursormode
- toggles the data cursor functionality in the current figure from the command line
- optional output argument creates a 'data cursor mode object' that can be accessed to set data tip properties
https://www.mathworks.com/help/matlab/ref/datacursormode.html

There appears to be a context menu option to Export data to Workspace. it prompts you for a name and then creates an struct containing graphics handle and point position. Far as I can tell there's no CLI function to produce the same behavior.

Nicholas Jankowski <nrjank>
Group Member
Mon 06 Mar 2017 08:56:05 AM UTC, original submission:  

Thanks to the work of Pantxo Diribarne (look here), I was able to hack Octave to get a data cursor in 2D plots.

Here is how to do in Octave 4.0.x or 4.2.x:

In the attached zip file, you'll find three .m files. Copy these three files to <prefix>/share/octave/<version>/m/plot/draw/private , where <prefix> is /usr for Linux, c:\octave for Windows, etc. and <version> is Octave version number.

2. Launch Octave gui and plot some curve, like this:

x=[0:0.01:2*pi]; y=sin(x); plot(x,y);

Then you'll see the sinus curve in a figure window. In the figure menu, at the rightmost position, you'll see a new 'Data' menu item, where you can add a new data cursor, show/hide data cursors or get cursor data. See the attached screenshot as an example.

You can have several data cursors at the same time, with different colors, fonts, etc. Just right click on a data cursor to change its properties.

This works with nearly all 2D plots (semilogx, semilogy, loglog, subplot) but doesn't work with 3D plots (the Data menu is not displayed in this case).

There are some minor issues, but it works quite well...

Note that, when you do a right mouse click, position the mouse on the arrow head and not on the text, otherwise the data cursor will move to the mouse position.

Roland Baudin <roland65>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #48977:  datacursorV4.diff added by philipnienhuis (8KiB - application/octet-stream)
file #48968:  datacursorV3.diff added by nrjank (26KiB - application/octet-stream)
file #40676:  datacursor-v3.zip added by roland65 (13KiB - application/zip)
file #40594:  datacursor-v2.zip added by roland65 (13KiB - application/zip - Updated version)
file #39902:  datacursor.zip added by roland65 (6KiB - application/zip)
file #39903:  figure.png added by roland65 (49KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by lt1234 (Posted a comment)
  • -email is unavailable- added by reikred (Posted a comment)
  • -email is unavailable- added by philipnienhuis
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by roland65 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-06-09 philipnienhuis Carbon-Copy- Added philipnienhuis
    2020-05-09 mmuetzel SummaryData cursor for Octave 4.0.x and 4.2.x Add data cursor functionality in plots
    2020-04-30 philipnienhuis Attached File- Added datacursorV4.diff, #48977
    2020-04-29 nrjank Attached File- Added datacursorV3.diff, #48968
    2017-05-12 roland65 Attached File- Added datacursor-v3.zip, #40676
    2017-05-05 roland65 Attached File- Added datacursor-v2.zip, #40594
    2017-03-06 roland65 Attached File- Added datacursor.zip, #39902
        Attached File- Added figure.png, #39903

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code