gca
Current axes or chart
Syntax
Description
returns the current axes (or standalone
visualization) in the current figure. Use ax
= gcaax
to get and set
properties of the current axes. If there
are no axes or charts in the current figure, then gca
creates a
Cartesian axes object.
Examples
Output Arguments
More About
Tips
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 on
gca
.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 figure
CurrentAxes
property. MATLAB® returns an empty array if there is no current axes.fig = gcf; ax = fig.CurrentAxes;
Version History
Introduced before R2006a