文件交流上好像有画3y轴的函数:
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
% x2,y2 are the
xdata and ydata for the second axes' line
% x3,y3 are the
xdata and ydata for the third axes' line
% ylabels is a
3x1 cell array containing the ylabel strings
%Outputs: ax - 3x1 double
array containing the axes' handles
% hlines - 3x1
double array containing the lines' handles
%Author: Denis Gilbert, Ph.D., physical
oceanography
%Maurice Lamontagne Institute
�pt. of Fisheries and Oceans Canada
%email:
%Web:http://www.qc.dfo-mpo.gc.ca/iml/
%April 2000; Last revision: 14-Nov-2001
if nargin==6
ylabels{1}=' '; ylabels{2}='
'; ylabels{3}=' ';
elseif nargin > 7
error('Too many input
arguments')
elseif nargin <6
error(&#39;Not enough input
arguments&#39;)
end
figure(&#39;units&#39;,&#39;normalized&#39;,...
&#39;DefaultAxesXMinorTick&#39;,&#39;on&#39;,&#39;DefaultAxesYminorTick&#39;,&#39;on&#39;);
[ax,hlines(1),hlines(2)] &#61; plotyy(x1,y1,x2,y2);
cfig &#61; get(gcf,&#39;color&#39;);
pos &#61;
[0.1 0.1 0.7 0.8];
offset &#61; pos(3)/5.5;
pos(3) &#61; pos(3) - offset/2;
set(ax,&#39;position&#39;,pos);
pos3&#61;[pos(1) pos(2) pos(3)&#43;offset pos(4)];
limx1&#61;get(ax(1),&#39;xlim&#39;);
limx3&#61;[limx1(1) limx1(1) &#43;
1.2*(limx1(2)-limx1(1))];
ax(3)&#61;axes(&#39;Position&#39;,pos3,&#39;box&#39;,&#39;off&#39;,...
&#39;Color&#39;,&#39;none&#39;,&#39;XColor&#39;,&#39;k&#39;,&#39;YColor&#39;,&#39;r&#39;,...
&#39;xtick&#39;,[],&#39;xlim&#39;,limx3,&#39;yaxislocation&#39;,&#39;right&#39;);
hlines(3) &#61;
line(x3,y3,&#39;Color&#39;,&#39;r&#39;,&#39;Parent&#39;,ax(3));
limy3&#61;get(ax(3),&#39;YLim&#39;);
line([limx1(2) limx3(2)],[limy3(1) limy3(1)],...
&#39;Color&#39;,cfig,&#39;Parent&#39;,ax(3),&#39;Clipping&#39;,&#39;off&#39;);
axes(ax(2))
set(get(ax(1),&#39;ylabel&#39;),&#39;string&#39;,ylabels{1})
set(get(ax(2),&#39;ylabel&#39;),&#39;string&#39;,ylabels{2})
set(get(ax(3),&#39;ylabel&#39;),&#39;string&#39;,ylabels{3})
% 例子
% x &#61; [0 0.1 0.2 0.3 0.4 0.426 0.5 0.6 0.688 0.7 0.8 0.9
1.0];
% y &#61; [268.95 272.36 275.07 277.07 277.93 278 276.5 267.16 248.2
244.3 200.37 137.71 58.7];
% a &#61; [0 0.225 0.408 0.566 0.693 0.718 0.776 0.82 0.831 0.831 0.818
0.784 0.6];
% k &#61; [2.55 2.254 2.063 1.886 1.733 1.687 1.552 1.368 1.207 1.187
1.023 0.873 0.6];
% ylabels{1}&#61;&#39;轴1&#39;;
% ylabels{2}&#61;&#39;轴2&#39;;
% ylabels{3}&#61;&#39;轴3&#39;;
% [ax,hlines] &#61; plotyyy(x,y,x,a,x,k,ylabels);
% legend(hlines, &#39;y &#61; x&#39;,&#39;a &#61;x&#39;,&#39;k &#61; x&#39;,2)