MATLAB plotyyy 函数 三Y轴绘制曲线(ZT)
| 分类: matlab相关 |
function
[ax,hlines] = plotyyy(x1,y1,x2,y2,x3,y3,ylabels)
%PLOTYYY - Extends plotyy to include a third y-axis
%
%Syntax: [ax,hlines] = plotyyy(x1,y1,x2,y2,x3,y3,ylabels)
%
%Inputs: x1,y1 are the xdata and ydata for the first axes'
line
%
%
%
%
%Outputs: ax
-
%
%
%Example:
%x=0:10;
%y1=x; y2=x.^2;
%ylabels{1}='First y-label';
%ylabels{2}='Second y-label';
%ylabels{3}='Third y-label';
%[ax,hlines] = plotyyy(x,y1,x,y2,x,y3,ylabels);
%legend(hlines, 'y = x','y = x^2','y = x^3',2)
%
%m-files required: none
%Author: Denis Gilbert, Ph.D., physical oceanography
%Maurice Lamontagne Institute
%email:
%Web:
%April 2000; Last revision: 14-Nov-2001
if nargin==6
elseif nargin > 7
elseif nargin < 6
end
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.1 0.1 0.7 0.8];
offset = pos(3)/5.5;
%Reduce width of the two axes generated by plotyy
pos(3) = pos(3) - offset/2;
set(ax,'position',pos);
pos3=[pos(1) pos(2) pos(3)+offset pos(4)];
limx1=get(ax(1),'xlim');
limx3=[limx1(1)
%Bug fix 14 Nov-2001: the 1.2 scale factor in the line above
%was contributed by Mariano Garcia (BorgWarner Morse TEC Inc)
ax(3)=axes('Position',pos3,'box','off',...
hlines(3) = line(x3,y3,'Color','r','Parent',ax(3));
limy3=get(ax(3),'YLim');
line([limx1(2) limx3(2)],[limy3(1) limy3(1)],...
axes(ax(2))
%Label all three y-axes
set(get(ax(1),'ylabel'),'string',ylabels{1})
set(get(ax(2),'ylabel'),'string',ylabels{2})
set(get(ax(3),'ylabel'),'string',ylabels{3})
http://hiphotos.baidu.com/hyyly520/pic/item/fc1c05a06e6c32cb471064bf.jpgplotyyy

加载中…