Discussion:
A hack to get a data cursor in Octave 4.0.x and 4.2.x
roland65
2017-03-01 12:49:57 UTC
Permalink
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 <Loading Image...>



--
View this message in context: http://octave.1599824.n4.nabble.com/A-hack-to-get-a-data-cursor-in-Octave-4-0-x-and-4-2-x-tp4682075.html
Sent from the Octave - General mailing list archive at Nabble.com.
Nicholas Jankowski
2017-03-01 15:23:43 UTC
Permalink
Post by roland65
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.
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)
roland65
2017-03-02 13:33:18 UTC
Permalink
Post by Nicholas Jankowski
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...




--
View this message in context: http://octave.1599824.n4.nabble.com/A-hack-to-get-a-data-cursor-in-Octave-4-0-x-and-4-2-x-tp4682075p4682115.html
Sent from the Octave - General mailing list archive at Nabble.com.
Nicholas Jankowski
2017-03-02 16:26:15 UTC
Permalink
Post by roland65
Post by Nicholas Jankowski
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.
roland65
2017-03-06 08:52:13 UTC
Permalink
Post by Nicholas Jankowski
Perhaps, but things often eventually get lost on the mailing list.
OK, you're right. I've done it and this is here
<https://savannah.gnu.org/patch/index.php?9280> in the patch section.




--
View this message in context: http://octave.1599824.n4.nabble.com/A-hack-to-get-a-data-cursor-in-Octave-4-0-x-and-4-2-x-tp4682075p4682179.html
Sent from the Octave - General mailing list archive at Nabble.com.
roland65
2017-05-05 13:34:35 UTC
Permalink
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
<https://savannah.gnu.org/patch/index.php?9280> .



--
View this message in context: http://octave.1599824.n4.nabble.com/A-hack-to-get-a-data-cursor-in-Octave-4-0-x-and-4-2-x-tp4682075p4683187.html
Sent from the Octave - General mailing list archive at Nabble.com.
roland65
2017-05-12 14:35:43 UTC
Permalink
Here <https://savannah.gnu.org/patch/index.php?9280#comment3> 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.



--
View this message in context: http://octave.1599824.n4.nabble.com/A-hack-to-get-a-data-cursor-in-Octave-4-0-x-and-4-2-x-tp4682075p4683311.html
Sent from the Octave - General mailing list archive at Nabble.com.
Reed, Darren K. (MSFC-ER42)
2017-03-01 16:28:30 UTC
Permalink
-----Original Message-----
From: Help-octave [mailto:help-octave-bounces+darren.k.reed=***@gnu.org] On Behalf Of roland65
Sent: Wednesday, March 01, 2017 6:50 AM
To: help-***@gnu.org
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
roland65
2017-03-02 13:36:51 UTC
Permalink
Post by Reed, Darren K. (MSFC-ER42)
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.




--
View this message in context: http://octave.1599824.n4.nabble.com/A-hack-to-get-a-data-cursor-in-Octave-4-0-x-and-4-2-x-tp4682075p4682116.html
Sent from the Octave - General mailing list archive at Nabble.com.
Reed, Darren K. (MSFC-ER42)
2017-03-02 17:46:27 UTC
Permalink
Post by roland65
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
roland65
2017-03-03 17:07:59 UTC
Permalink
Post by Reed, Darren K. (MSFC-ER42)
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.





--
View this message in context: http://octave.1599824.n4.nabble.com/A-hack-to-get-a-data-cursor-in-Octave-4-0-x-and-4-2-x-tp4682075p4682146.html
Sent from the Octave - General mailing list archive at Nabble.com.
Reed, Darren K. (MSFC-ER42)
2017-03-03 19:11:11 UTC
Permalink
#> 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
Loading...