Current axes or chart
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
following types of objects can become the current axes. Typically, it is the last
one of these objects that is created, clicked on, or plotted into.
A standalone visualization, which is a chart designed for a special
purpose that works independently from other charts. For example, a
heatmap is a standalone
visualization for observing the interaction between two variables in
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
property. MATLAB® returns an empty array if there is no current axes.
fig = gcf; ax = fig.CurrentAxes;