matlab双y轴

clc
clear
close all


Sita = 0:0.25:5;
y1 = -20000./(1.6.*Sita.^2-288.00);
y2 = -20000./(1.2.*Sita.^2-208.00);
y3 = -56000./(1.92.*Sita.^2-294.400);
y4 = -80000./(0.92.*Sita.^2-64.00);

figure;
hold on
set(gcf, 'Position', [176,193,621,526]); 
%左轴
yyaxis left;
h1 = plot(Sita,y1,'-s','color',[0,44,83]/255,'linewidth',1.5);
plot(Sita,y2,'-s','color',[255,165,16]/255,'linewidth',1.5);
plot(Sita,y3,'-s','color',[12,132,198]/255,'linewidth',1.5);
%显示范围
% xlim([0,5]);
ylim([45,300]);
%坐标轴刻度
% yticks([0.6e6 0.8e6 1.0e6 1.2e6 ])
set(gca,'ycolor',[0 0 0]);

yl = ylabel({'\it\fontname{Times New Roman}y_{CS}^{M1}\rm\fontname{Times New Roman}\cdot{10}','\it\fontname{Times New Roman}y_{CS}^{M2}\rm\fontname{Times New Roman}\cdot{10}','\it\fontname{Times New Roman}y_{CS}^{M3}\rm\fontname{Times New Roman}\cdot{10}'});

set(yl,'Rotation',0,'position',[-0.6 150]);
%右轴
yyaxis right;
%显示范围
% xlim([0,5]);
ylim([-200,2000]);
h2 = plot(Sita,y4,'-d','color',[247,77,77]/255,'linewidth',1.5);
set(gca,'ycolor',[0 0 0]);
%坐标轴刻度
% yticks([1e5 2e5 3e5 4e5])
%坐标轴标签
yr = ylabel('\it\fontname{Times New Roman}y_{CS}^{M4}\rm\fontname{Times New Roman}\cdot{10}');
set(yr,'Rotation',0,'position',[5.7 1100]);
xlabel('\theta ');
box on
grid on
legend({'\it\fontname{Times New Roman}y_{CS}^{M1}','\it\fontname{Times New Roman}y_{CS}^{M2}','\it\fontname{Times New Roman}y_{CS}^{M3}','\it\fontname{Times New Roman}y_{CS}^{M4}'});

posted @ 2023-04-29 10:14  Ada_CN  阅读(93)  评论(0编辑  收藏  举报