Quantcast

A hack to get a data cursor in Octave 4.0.x and 4.2.x

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

A hack to get a data cursor in Octave 4.0.x and 4.2.x

roland65
Hi,

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 attched 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...

datacursor.zip
figure.png
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: A hack to get a data cursor in Octave 4.0.x and 4.2.x

NJank
On Wed, Mar 1, 2017 at 7:49 AM, roland65 <[hidden email]> wrote:
Hi,

thanks to the work of Pantxo Diribarne (look  here
<http://octave.1599824.n4.nabble.com/Data-cursor-in-Octave-td4681801.html#a4681956>
), 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 attched zip file, you'll find three .m files.

Sounds like something that could be proposed as a patch for inclusion in octave. Have you put anything forward on either the bug or patch tracker? I don't see anything existing, but matlab does have a datacursormode function to enable/disable it's data cursor functionality. Is there anything here that could be done here to provide similar functionality and also improve function compatibility? (I realize that gui behavioral compatibility somewhat less of a priority)

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: A hack to get a data cursor in Octave 4.0.x and 4.2.x

Reed, Darren K. (MSFC-EV33)
In reply to this post by roland65


-----Original Message-----
From: Help-octave [mailto:help-octave-bounces+darren.k.reed=[hidden email]] On Behalf Of roland65
Sent: Wednesday, March 01, 2017 6:50 AM
To: [hidden email]
Subject: A hack to get a data cursor in Octave 4.0.x and 4.2.x

Hi,

thanks to the work of Pantxo Diribarne (look  here <http://octave.1599824.n4.nabble.com/Data-cursor-in-Octave-td4681801.html#a4681956>
), 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 attched 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...

datacursor.zip
<http://octave.1599824.n4.nabble.com/file/n4682075/datacursor.zip>
figure.png <http://octave.1599824.n4.nabble.com/file/n4682075/figure.png>  

------------------------------------------------------------------------------------------------------
Hello,
I am a Windows 7/64bit user and tried using the above scripts without success.  I don't think I put them in the correct place.  Does anyone know where to put these files?  Or is there something else needed to do to make them work.  I was able to make the original data cursor work ??

Thanks,
Darren


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: A hack to get a data cursor in Octave 4.0.x and 4.2.x

roland65
In reply to this post by NJank
NJank wrote
Sounds like something that could be proposed as a patch for inclusion in
octave.
This data cursor stuff is merely a hack. I don't think developers would agree to add this to the official Octave branch...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: A hack to get a data cursor in Octave 4.0.x and 4.2.x

roland65
In reply to this post by Reed, Darren K. (MSFC-EV33)
Reed, Darren K. (MSFC-EV33) wrote
Does anyone know where to put these files?
If you have installed Octave 4.2.1 in c:\Octave, then you'll have to copy the three .m files to:

C:\Octave\Octave-4.2.1\share\octave\4.2.1\m\plot\draw\private

There is nothing else to do.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: A hack to get a data cursor in Octave 4.0.x and 4.2.x

NJank
In reply to this post by roland65
On Thu, Mar 2, 2017 at 8:33 AM, roland65 <[hidden email]> wrote:
NJank wrote
> Sounds like something that could be proposed as a patch for inclusion in
> octave.

This data cursor stuff is merely a hack. I don't think developers would
agree to add this to the official Octave branch...


Perhaps, but things often eventually get lost on the mailing list.  Even if it gets marked low priority / won't fix / whatever, putting this on the tracker gives it a permanent home, puts it somewhere that someone else might find later, and maybe serves as a starting point for a less hack-ish hack.

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: A hack to get a data cursor in Octave 4.0.x and 4.2.x

Reed, Darren K. (MSFC-EV33)
In reply to this post by roland65

> If you have installed Octave 4.2.1 in c:\Octave, then you'll have to copy the three .m files to:

> 

> C:\Octave\Octave-4.2.1\share\octave\4.2.1\m\plot\draw\private

> 

> There is nothing else to do.

 

Ok.  Moved them to the correct location and the data cursor works.  Very nice! However, when I do a right mouse click, the cursor just moves to the new mouse location.  You cannot edit the values or change colors.

I am using Octave 4.0.3 under Windows 7 / 64bit

 

Thanks,

Darren

 


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: A hack to get a data cursor in Octave 4.0.x and 4.2.x

roland65
Reed, Darren K. (MSFC-EV33) wrote
when I do a right mouse click, the cursor just moves to the new mouse location.  You cannot edit the values or change colors
The trick is to position the mouse on the arrow head and not on the text. You can then modify the text color, text font, arrow / line properties, and you can also change the displayed values using the String property.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: A hack to get a data cursor in Octave 4.0.x and 4.2.x

Reed, Darren K. (MSFC-EV33)
In reply to this post by roland65

#> Reed, Darren K. (MSFC-EV33) wrote

#>  when I do a right mouse click, the cursor just moves to the new mouse

#>  location.  You cannot edit the values or change colors

#

# The trick is to position the mouse on the arrow head and not on the text.

# You can then modify the text color, text font, arrow / line properties, and you can also change the displayed #values using the String property.

 

Ok.  That works great.  Now I have to remember the trick ;^}

I agree that this would be a useful addition to a future Octave version.

 

Thank you,

Darren

 


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: A hack to get a data cursor in Octave 4.0.x and 4.2.x

roland65
In reply to this post by NJank
NJank wrote
Perhaps, but things often eventually get lost on the mailing list.
OK, you're right. I've done it and this is here in the patch section.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: A hack to get a data cursor in Octave 4.0.x and 4.2.x

roland65
I've updated the data cursor menu and functions:

- the issue with the right click mouse button is fixed
- the Data menu now also appears in stem and stairs plots

Instructions and files are here.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: A hack to get a data cursor in Octave 4.0.x and 4.2.x

roland65
This post was updated on .
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.
Loading...