MATLAB ploty4 函数 四Y轴绘制曲线

标签:
杂谈 |
分类: matlab |
function [ax,hlines] =
ploty4(x1,y1,x2,y2,x3,y3,x4,y4,ylabels)
%PLOTY4
%
% Syntax:
%
% Inputs:
%
%
%
%
%
% Outputs: ax
-
%
%
% Example:
%
%
%
%
%
%
%
%
%
% See also Plot, Plotyy
% Based on plotyyy.m (available at www.matlabcentral.com) by
:
% Denis Gilbert, Ph.D.
% Check inputs
msg=nargchk(8,9,nargin);
error(msg);
% Create figure window
figure('units','normalized',...
%Plot the first two lines with plotyy
[ax,hlines(1),hlines(2)] = plotyy(x1,y1,x2,y2);
cfig = get(gcf,'color');
pos = [0.125 0.1 0.65 0.8];
offset = pos(3)/5.5;
%Reduce width of the two axes generated by plotyy
pos(1) = pos(1) + offset;
pos(3) = pos(3) - offset;
set(ax,'position',pos);
�termine the position of the third/fourth axes
pos3 = [pos(1) pos(2) pos(3)+offset pos(4)];
pos4 = [pos(1) - offset pos(2) pos(3)+offset pos(4)];
�termine the proper x-limits for the third and fourth axes
scale3 = pos3(3)/pos(3);
scale4 = pos4(3)/pos(3);
limx1 = get(ax(1),'xlim');
limx3 = [limx1(1) limx1(1)+scale3*(limx1(2)-limx1(1))];
limx4 = [limx1(2)-scale4*(limx1(2)-limx1(1)) limx1(2)];
%Create ax(3) & ax(4)
ax(3) = axes('Position',pos3,'box','off',...
ax(4) = axes('Position',pos4,'box','off',...
%Plot x3,y3,x4,y4
hlines(3) = line(x3,y3,'Color','r','Parent',ax(3));
hlines(4) = line(x4,y4,'Color','k','Parent',ax(4));
%Put ax(2) on top;
axes(ax(2));
%Set y-labels;
if nargin==9
end