Getting value of data point on a plot in octave
Getting value of data point on a plot in octave
I am trying out octave as an alternative to matlab and it looks like the graph plot in octave is not as interactive as matlab
I want to find out the value of the x and y coordinates of a data point on the plot by clicking on it
I have seen the ginput function, but while my figure is open, if I call the function, click on a point in the figure and then press the Enter key, I get the following result:
[x, y, buttons] = ginput ()
x = (0x0)
y = (0x0)
buttons = (0x0)
While messing around I did manage to get proper coordinate values once
figure(1); [x, y, buttons] = ginput ()
x = 69.09677419354838
y = 127.2917862029395
buttons = 13
but I am not sure what I did different, and I haven;t been able to make it happen again
How can I click on a data point in in Octave figure and find it's value (both x and y, or at least just y)? Is it possible to select an exact data point on a plot using the ginput or any other function in Octave?
I've just tested "ginput" as well, and it appears that a bug has been introduced. I would encourage you to submit a bug (if one is not already present). In the meantime, you can use
get(gca, 'currentpoint')
to do what you want as a workaround.– Tasos Papastylianou
Sep 4 '18 at 7:41
get(gca, 'currentpoint')
@Tasos It is octave-4.4.1-w32 and I am using GUI. Is it possible to get a more interactive graph plot (similar to matlab, with at least the feature to click and view data points) in octave?
– user13267
Sep 4 '18 at 7:45
It appears that keyboard events are registered properly, whereas mouse events are ignored. The time you got a reply was probably when you pressed a key (not sure what key 13 is though)
– Tasos Papastylianou
Sep 4 '18 at 7:46
@Tasos and it is actually the zip file version not a full install
– user13267
Sep 4 '18 at 7:46
1 Answer
1
The behaviour described above seems to be a bug with the QT interface. The fltk interface works as expected. Try:
graphics_toolkit fltk
to enable it.
I will file a bug in the meantime. bug submitted
PS. Keyboard events seem to be detected normally, but mouse events are not, hence the empty lists. The '13' accidental output must have been from pressing 'small enter' and registering a newline keyboard event, before pressing 'big enter' thus forcing ginput
to return.
ginput
UPDATE it appears that switching back to the qt interface and trying again now allows mouse events to work. This has persisted following an octave restart. Weird bug.
Just a minor question, small enter is the one next to the num pad and the big enter is the one in the centre of the keyboard?
– user13267
Sep 4 '18 at 7:57
yes that's right
– Tasos Papastylianou
Sep 4 '18 at 7:58
@user13267 see the update. maybe this will work for you as well?
– Tasos Papastylianou
Sep 4 '18 at 8:02
@user13267 btw, to answer the implied second part of your question: No unfortunately octave does not have the same graphical 'data tool' as matlab. I would simply recommend plotting with added markers, and using ginput; if you want more accurate measurements, then zoom in before using ginput, but that's about it. You can also inspect the plot object's 'xdata' and 'ydata' and write a small function that gets the nearest point to that.
– Tasos Papastylianou
Sep 4 '18 at 8:16
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Please mention which version of octave you're using and if it's GUI or console. The default GUI interface shows the coordinates prominently on the bottom left of the figure as you hover with your mouse.
– Tasos Papastylianou
Sep 4 '18 at 7:38