博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【转】MATLAB在一幅图上添加多个纵坐标轴
阅读量:1523 次
发布时间:2019-04-21

本文共 2443 字,大约阅读时间需要 8 分钟。

来源:http://wenku.baidu.com/link?url=m_eEkzbjnT9ccgAnlPVDqHCVyrZOD2EplXxxIiQc69DI0lHAWzwpZXfdDy_7DPbwIXC4t6c1zi9WfI5dlf6HETC1Mc69FjAAPstpIic_hBe

 

代码:

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
%Dept. of Fisheries and Oceans Canada
%email: gilbertd@dfo-mpo.gc.ca  
%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('Not enough input arguments')
end
figure('units','normalized',...
       'DefaultAxesXMinorTick','on','DefaultAxesYminorTick','on');
[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;
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)   limx1(1) + 1.2*(limx1(2)-limx1(1))];
ax(3)=axes('Position',pos3,'box','off',...
   'Color','none','XColor','k','YColor','r',...   
   'xtick',[],'xlim',limx3,'yaxislocation','right');
hlines(3) = line(x3,y3,'Color','r','Parent',ax(3));
limy3=get(ax(3),'YLim');
line([limx1(2) limx3(2)],[limy3(1) limy3(1)],...
   'Color',cfig,'Parent',ax(3),'Clipping','off');
axes(ax(2))
set(get(ax(1),'ylabel'),'string',ylabels{1})
set(get(ax(2),'ylabel'),'string',ylabels{2})
set(get(ax(3),'ylabel'),'string',ylabels{3})

 

实例:

在Commond Window里运行:

代码:

x = [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 = [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 = [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 = [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}='轴1';
ylabels{2}='轴2';
ylabels{3}='轴3';
[ax,hlines] = plotyyy(x,y,x,a,x,k,ylabels);
legend(hlines, 'y = x','a =x','k = x',2)

转载于:https://www.cnblogs.com/Dontstop/p/4792776.html

你可能感兴趣的文章
安全合规--47--基于国内法律法规的企业数据合规体系建设经验总结(六)
查看>>
安全合规--48--基于国内法律法规的企业数据合规体系建设经验总结(七)
查看>>
安全合规--49--基于国内法律法规的企业数据合规体系建设经验总结(八)
查看>>
安全合规--50--基于国内法律法规的企业数据合规体系建设经验总结(九)
查看>>
Suricata+ELK集群监控办公网流量
查看>>
安全架构--4--一个优秀的团队管理者所应具备的能力
查看>>
安全架构--5--我设计的企业安全体系架构
查看>>
Python3开发--23--搭建Django商城项目架构
查看>>
Python3开发--24--Django项目的路由设计
查看>>
Python3开发--25--Django项目的数据模型搭建与使用
查看>>
Python3开发--26--Django项目的业务数据处理
查看>>
web渗透--1--web安全原则(上)
查看>>
web渗透--3--web渗透测试清单
查看>>
web渗透--4--自动化漏洞扫描
查看>>
web渗透--5--Google Hacking
查看>>
web渗透--6--web服务器指纹识别
查看>>
web渗透--7--枚举web服务器应用
查看>>
web渗透--8--识别web应用框架
查看>>
web渗透--9--配置管理测试
查看>>
web渗透--10--身份管理测试
查看>>