%% Changing Axes Properties
% This example shows how to get properties of an axes in MATLAB® and change axes property values to customize your graph.
%
%% Axes Objects
% All plots are contained within an axes.

x = linspace(0,12);
y = 10*exp(-0.65*x);

figure
plot(x,y)

%
% The gca function returns the current axes for the current figure. Like all graphics objects, axes have properties that you can view and modify. These properties have default values. The display of the axes object, ax, shows the most commonly used axes properties, such as XLim, YLim, XScale, and YScale.

ax = gca

%
%% Get Individual Axes Properties
% To access individual properties, use dot notation syntax object.PropertyName. For example, return the x-axis limits.

ax.XLim

%
%% Change Commonly Used Axes Properties
% Several functions are available to change axes properties. For example, use the axis function to change the axes scaling and appearance.

axis square

%
% Use the xlim, ylim, and zlim functions to change the axes limits.

xlim([0 10])

%
% Use the xlabel, ylabel, and zlabel functions to label the axes.

xlabel('x')
ylabel('exp(x)')

%
%% Change Other Axes Properties
% To customize the look of the axes, change property values using dot notation syntax object.PropertyName.

ax.YScale = 'log';    % set y-axis to logarithmic scaling
ax.FontSize = 12;     % set font size for axes labels
ax.XGrid = 'on';      % draw gridlines perpendicular to x-axis
ax.YGrid = 'on';      % draw gridlines perpendicular to y-axis

%
%% Get All Axes Properties
% Graphics objects in MATLAB have many properties. To see all the properties of an object, use the get command.

get(ax)

%
% Copyright 2014 The MathWorks, Inc.