%% Create Multiple Plots Within Figure and Label Axis with Month Names  

% Copyright 2015 The MathWorks, Inc.


%% 
% Select a starting date and an ending date. 
startDate = datenum('01-01-2009');
endDate = datenum('12-31-2009');  

%% 
% Create a variable, |xdata|, that corresponds to the number of months between
% the start and end dates. 
xData = linspace(startDate,endDate,12);  

%% 
% Plot random data. 
ax1 = subplot(2,1,1);
bar(xData,rand(1,12))
ax2 = subplot(2,1,2);
bar(xData,rand(1,12))  

%% 
% Set the number of |XTicks| to the number of points in |xData|. Label the
% _x_-axis of each subplot with month names, referring to each subplot
% using its axes handle. Preserve the total number of ticks by using the
% |'keepticks'| option. Starting in R2014b, you can use dot notation to set
% properties. If you are using an earlier release, use the
% <docid:matlab_ref.f67-432995> function instead.

ax1.XTick = xData; 
datetick(ax1,'x','mm','keepticks')

ax2.XTick = xData; 
datetick(ax2,'x','mmm','keepticks')
     

