Can you set figure axis properties without using gca as argument to the set command?
Ältere Kommentare anzeigen
I know you can save a structure variable for the current axis using get(gca); however, that structure seems useless except to list items within it.
For example:
axishandle = get(gca); axishandle.XTick
will display the current x-axis tick values on the command line, but both of the following commands are invalid:
set(axishandle.XTick,[0 0.5 1]) set(axishandle.XTick,'XTick',[0 0.5 1])
However,
set(gca,[0 0.5 1])
is valid--so what is the point of being able to assign a handle to the current axis?
Akzeptierte Antwort
Weitere Antworten (1)
Sean de Wolski
am 9 Sep. 2014
I think you're misunderstanding the handle and output from get.
axHandle = gca
Will give you the handle to the axes. You can think of this as a phone number with which you can query or set the axes.
props = get(gca)
Gives you a static structure of what all of the properties are at the time. This does not update and you would have to rerun it any time you want current properties.
If you want a specific property (rather than all of them), just get it
xt = get(gca,'XTick')
The purpose of being able to store the handle to gca is so that you can have multiple axes and control which one gets the update or whose properties you're querying even if the axes you care about is not current.
axh1 = subplot(1,2,1);
axh2 = subplot(1,2,2);
Now regardless of which one is current I can grab pieces of either.
1 Kommentar
Seth Wagenman
am 9 Sep. 2014
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!