How to return value from an axes ?

3 次查看(过去 30 天)
Hello all, How to return value of an axes in GUI, which is typically a numeric value. That value can be used to handle the axes outside the axes function also. thank you

采纳的回答

Walter Roberson
Walter Roberson 2016-2-29
As of R2014b, graphics handles are no longer numeric values. There is not a lot of reason to need a numeric value for a graphics handle: you can just store and pass around the object-oriented handle instead.
If you really really need to get to the numeric value for some reason, then you can double() the object-oriented handle, but be warned that if you do so the recipients cannot make use of that to refer to the axes, not without using handle() on it. The only reason I have ever had for needing to know the numeric value of a graphics handle (other than a figure handle) is for debugging.
If you want to know the handle of the "current" axes, then call gca()
If you built the axes using GUIDE, and gave it a Tag, then you can pull its handle out of the "handles" structure by using the Tag as a field name.
If you create the axes at run-time, then record its handle and pass that around as needed
ax1 = axes('Units', 'norm', 'Position', [0 0 .3 .3]);
....
do_something_with_an_axes(ax1)
If you want to know the axes that a particular drawing object such as a lineseries object, then you can use ancestor(HandleOfGraphicsObject, 'axes')
If you created the axes with a Tag and the Tag is unique, you can findobj() or findall() against the Tag to find the axes. (If the tag is not unique, you would get all of the objects with the tag.) This is slower than the alternatives listed above, but can be very convenient.
  2 个评论
yogesh jain
yogesh jain 2016-2-29
Hello Mr. Roberson , Thank you. I want to ask that how can I change this approach for using in GUIs . question It uses subplot function for showing children axes but I am using different axes in GUI . What should be the changes ?
Thanks again :)
Walter Roberson
Walter Roberson 2016-2-29
Nothing I have written is any different for GUI, other than the fact that when I am writing a GUI I would be even less likely to look at the numeric value of a handle and more likely to store the handles and refer to the stored handles.

请先登录,再进行评论。

更多回答(1 个)

Deependra Mishra
Deependra Mishra 2018-12-13
Here is a link I found, anyone one who come across this might want to have a look at...

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by