MATLAB Examples

This is an example of how to customize axes settings in a plot in MATLAB®.

Read about the XAxis property in the MATLAB documentation. This feature is available in R2015b or newer.

For more examples, go to MATLAB Plot Gallery

% Create a stem plot
profit = [20 40 50 40 50 60 70 60 70 60 60 70 80 90];
yr = 2001:2014;
stem(yr,profit)

% Add label and title
xlabel('Month')
ylabel('Profit')
title('Amount of profit over 14 year')

% Change axis properties
ax = gca;
ax.XAxis.Limits = [2000 2015];
ax.XAxis.TickValues = yr;
ax.XAxis.TickLabelRotation = 30;
ax.XAxis.FontWeight = 'bold';
ax.XAxis.FontAngle = 'italic';

ax.YAxis.TickLabelFormat = '$%,.0fM';