%% Set Properties for Chart with Two y-Axes
% The yyaxis command creates an axes object with y-axes on the left and right sides. Axes properties related to the y-axis have two values. However, MATLAB gives access only to the value for the active side. For example, if the left side is active, then the YDir property of the axes object contains the direction for the left y-axis. Similarly, if the right side is active, then the YDir property contains the direction for the right y-axis. An exception is that the YAxis property of the axes object contains an array of two numeric ruler objects (one for each y-axis).
% To change the appearance and behavior of a particular y-axis, either set the active side, and then change property values for the axes object, or use the numeric ruler objects.
%% Change Axes Properties
% Create a chart with two y-axes and plot data. Reverse the direction for each y-axis. Use yyaxis left to activate the left side. Next, set the direction for the left y-axis. Similarly, use yyaxis right to activate the right side. Then, set the direction for the right y-axis.

x = [1 2 3];
y1 = [2 6 4; 3 5 4; 5 7 8];
y2 = 100*[5 5 3; 3 4 7; 5 6 3];
figure
yyaxis left
plot(x,y1)
yyaxis right
plot(x,y2)

ax = gca;
yyaxis left
ax.YDir = 'reverse';
yyaxis right
ax.YDir = 'reverse';

%
%% Change Numeric Ruler Properties
% Reverse the directions by setting properties of the numeric ruler objects. Use ax.YAxis(1) to refer to the left side and ax.YAxis(2) to refer to the right side.

x = [1 2 3];
y1 = [2 6 4; 3 5 4; 5 7 8];
y2 = 100*[5 5 3; 3 4 7; 5 6 3];
figure
yyaxis left
plot(x,y1)
yyaxis right
plot(x,y2)

ax = gca;
ax.YAxis(1).Direction = 'reverse';
ax.YAxis(2).Direction = 'reverse';

% Copyright 2012 The MathWorks, Inc.