%% Controlling Individual Axis Properties in a Plot
% This example shows how to get properties of a ruler in MATLAB® and change ruler property values to customize an individual axis in your plot.
%
%% Numeric Ruler Objects
% Create a plot and label the x-axis and y-axis.

x = linspace(0,5,1000);
y = 100*exp(x).*sin(20*x);
plot(x,y)

xlabel('x')
ylabel('y')

%
% MATLAB creates a numeric ruler for each axis. Numeric ruler objects controls the marks, tick labels, and axis labels for a given coordinate (x, y, or z). Access the numeric ruler object associated with a particular axis through the XAxis, YAxis, or ZAxis property of the axes object. Like all graphics objects, numeric rulers have properties that you can view and modify.

ax = gca;
ax.XAxis   % the numeric ruler object for the x-axis

%
%% Customize Appearance of Individual Axes Labels
% Customize the look of your plot by changing the ruler properties using dot notation. For example, change the appearance of the x-axis labels by setting the FontAngle and FontSize Properties of the corresponding numeric ruler.
%
%

ax.XAxis.FontAngle = 'italic';
ax.XAxis.FontSize = 12;

%
%% Changing Exponent Value for Tick Labels
% For larger values, MATLAB automatically scales the tick labels and adds an exponent to the display. Set the Exponent property of the numeric ruler associated with the y-axis to change the exponent value for the y-axis. The exponent label and the tick labels change accordingly.

ax.YAxis.Exponent = 2;

%
%% Customize Format of Tick Value Labels
% Customize the format of the tick value labels for the y-axis by setting the TickLabelFormat property of the numeric ruler associated with the y-axis.
% Display the tick label values along the y-axis as U.S.dollar values with two decimal places by setting the TickLabelFormat property to '$%,.2f'. The TickLabelFormat property uses the same format operators as the printf function.

profit = [20 40 50 40 50 60 70 60 70 60 60 70 80 90];
stem(profit)
xlim([0 15])

ax = gca;
ax.YAxis.TickLabelFormat = '$%,.2f';

%
% Change other properties of the numeric ruler object to customize other aspects of an individual axis including color, width, and minor tick values.
%
%% Get All Numeric Ruler Properties
% Graphics objects in MATLAB have many properties. To see all the properties of a numeric ruler, use the get command. The numeric ruler object and the axes object have several common properties. If you set the axes property, the axes passes the value to the corresponding ruler property. However, you can change ruler properties independently to customize an individual axis.

get(ax.YAxis)

%
% Copyright 2015 The MathWorks, Inc.