%% Set Colors for Active Side of Plot with Two y-Axes
% Setting the color order for the figure after calling yyaxis sets the color for the active side.
% Activate the left y-axis and plot three lines. Set the line style order to one solid line and change the y-axis color to blue. Then set the color order to three shades of blue.

% Left side
yyaxis left
plot([1 2 3; 4 5 6])
ax = gca;
ax.LineStyleOrder = '-';
ax.YColor = 'blue';
leftcolors = [0 0 1; 0 0.50 1; 0 0.80 1];
colororder(leftcolors)

%
% Activate the right y-axis and plot two lines. Change the y-axis color to black. Then set the color order to black.

% Right side
yyaxis right
plot([4 3; 2 1])
ax.YColor = 'black';
colororder('black')

% Copyright 2019 The MathWorks, Inc.