Current axes or chart
returns the current axes (or standalone visualization) in the current figure. Useax
= gcaax
to get and set properties of thecurrent axes. If there are no axes or charts in the current figure, thengca
creates a Cartesian axes object.
User interaction can change the current axes or chart. It is better to assign the axes or chart to a variable when you create it instead of relying ongca
.
Changing the current figure also changes the current axes or chart.
Set axes properties after plotting since some plotting functions reset axes properties.
To access the current axes or chart without forcing the creation of Cartesian axes, use dot notation to query the figureCurrentAxes
property. MATLAB®returns an empty array if there is no current axes.
fig = gcf; ax = fig.CurrentAxes;