matlab画双坐标图

整理了一下matlab画双坐标的代码,具体如下。如果想分别设置双坐标的label,可以设置Ylim,YTick和YTickLabel。

clc;clear;
x=1:20;
y1=100*ones(1,20);
y2=61:1:80;
figure(1)
[ax,h1,h2]=plotyy(x,y1,x,y2,'plot','plot');
xlabel('aa','Fontsize', 16,'Interpreter','latex')
set(ax(1),'XColor','k','YColor','b');
set(ax(2),'XColor','k','YColor','r');
%坐标1标注
set(get(ax(1),'Ylabel'),'String','y1','Fontsize', 16,'Interpreter','latex','color','b');
set(h1,'LineStyle','-','marker','*','color','b');
%坐标2标注
set(get(ax(2),'Ylabel'),'String','y2','Fontsize', 16,'Interpreter','latex','color','r');
set(h2,'LineStyle','-','marker','*','color','r');
%legend
legend({'y1','y2'},'Location','NorthWest')
legend boxoff;
box off
ax2 = axes('Position',get(gca,'Position'),...
           'XAxisLocation','top',...
           'YAxisLocation','right',...
           'Color','none'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值