Current axes or chart
Specify Properties for Current Axes
Plot a sine wave.
x = linspace(0,10); y = sin(4*x); plot(x,y)
Set the font size, tick direction, tick length, and y-axis limits for the current axes. Use
gca to refer to the current axes.
ax = gca; % current axes ax.FontSize = 12; ax.TickDir = 'out'; ax.TickLength = [0.02 0.02]; ax.YLim = [-2 2];
The current axes is the default target object for many graphics
commands, such as
xlim. The following types of objects can become the current
axes. Typically, it is the last one of these objects that is created, clicked on, or
A standalone visualization, which is a chart designed for a special purpose that works independently from other charts. For example, a
heatmapis a standalone visualization for observing the interaction between two variables in tabular data.
CurrentAxes property of a figure stores its current
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
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
CurrentAxesproperty. MATLAB® returns an empty array if there is no current axes.
fig = gcf; ax = fig.CurrentAxes;
Introduced before R2006a