Current axes handle
Create a plot of a sine wave. Set the font size, tick direction, tick length, and y-axis limits for the current axes using the gca command.
x = linspace(0,10); y = sin(4*x); figure; plot(x,y); set(gca,'FontSize',12,... 'TickDir','out',... 'TickLength',[.02,.02],... 'YLim',[-2,2])
The current axes is the target for graphics output. It is the axes in which graphics commands such as plot, text, and surf draw their results. It is typically the last axes created or the last axes clicked with the mouse. Changing the current figure also changes the current axes.
To view a list of all the axes properties, execute get(gca) or see the Axes Properties help page. Set axes properties after plotting since some plotting functions reset axes properties.
To get the handle of the current axes without forcing the creation of an axes if one does not exist, query the figure CurrentAxes property.
h = get(gcf,'CurrentAxes')
MATLAB® returns h as an empty array if there is no current axes.
User interaction can change the current axes. To be sure you are accessing the correct axes, store the axes handle in your program code and use this handle instead of gca.