gca - Current axes or chart - MATLAB (original) (raw)

Main Content

Syntax

Description

[ax](#btxcrct-1-ax) = gca returns the current axes (or standalone visualization) in the current figure. Use ax 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.

example

Examples

collapse all

Plot a sine wave.

x = linspace(0,10); y = sin(4*x); plot(x,y)

Figure contains an axes object. The axes object contains an object of type line.

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];

Figure contains an axes object. The axes object contains an object of type line.

Output Arguments

collapse all

Current axes, returned as an Axes object, aPolarAxes object, a GeographicAxes object, or a standalone visualization such as a heatmap.

More About

collapse all

The current axes is the default target object for many graphics commands, such as plot, title, andxlim. 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 plotted into.

The CurrentAxes property of a figure stores its current axes.

Tips

Version History

Introduced before R2006a