There are many methods on the net for the Double Y axis of Matlab, but there are very few Double Y axes with confidence intervals. In addition, the examples on the Net generally use red and blue colors, black or gray colors are too bright for anyone who just wants to use them ~
A curve with confidence intervals on the Double Y axis drawn using Matlab. The black one is drawn based on the left Y axis, and the gray curve is drawn based on the right Y axis. The MATLAB program is as follows:
[Ax, H1, H2] = plotyy (x, Y2, X, Z1, @ (x, Y2) errorbar (x, Y2, L2, U2, 'K-^ ', 'linewidth', 2), @ (x, Z1) errorbar (x, Z1, L3, U3, 'color', [138 138 138]/255, 'linestyle ', '-', 'marker', 'O', 'linewidth', 2 ));
% Plotyy is a function of the Double Y axis. X is the common x-axis coordinate of the two curves. Y2 is the y-axis coordinate of the Left Y axis, and z1 is the y-axis coordinate of the right;
% Errorbar is a function used to draw a confidence interval. The content includes the X axis, Y axis coordinate, the lower limit and upper limit of the value, and the line type and width are set later. Common line types are easy to change. If you want to change the color of a line to another type, you must separate these attributes. For example, you must use 'color' and linestyle for the color '. Point Type Function 'marker '. (Generally, 'markerstyle' is used in the introduction on the Internet, but this attribute always reports an error in my MATLAB version. It takes only half a day to find 'marker ');
Set (get (ax (1), 'ylabel'), 'string', 'B', 'fontweight ', 'bold', 'fontsize', 13 );
% Set the font size of the Left Y axis, in bold;
Set (get (ax (2), 'ylabel'), 'string', 'C', 'fontweight ', 'bold', 'fontsize', 13 );
% Set the font size of the right Y axis, in bold;
Set (ax (1), 'ylim', [0,750], 'fontweight ', 'bold', 'fontsize', 13 );
% Set the value range of the Left Y axis. It turns out that even if the value interval and range are set later, setting ylim cannot be omitted;
Set (ax (2), 'ylim', [-20, 80], 'fontweight ', 'bold', 'fontsize', 13 );
Set (ax (1), 'yzick', [0: 150: 750]);
% Set the value interval and range of the Left Y axis;
Set (ax (2), 'yzick', [-20: 20: 80]);
Set (ax (1), 'ycolor', 'k ')
% Set the color of the Left Y axis;
Set (ax (2), 'ycolor', [138 138 138]/255)
% Set the color of the right Y axis-gray;
% Are you sure you want to combine the preceding attributes?
Xlabel ('A', 'fontweight ', 'bold', 'fontsize', 13)
Legend ([H1, H2], {'B', 'C'}, 'fontweight ', 'bold', 'fontsize', 13)
% Set the legend of the Double Y axis
I hope I can help some people who want to combine a few simple images ~~