Plot not displaying the y axis limits, even though "ylim" has been used.
Show older comments
I have used Ylim to set the Y-axis limit for my plot. It seems to be working for one end of the y axis, but not at the other end. Xan someone tell me what could be wrong with my plots here. I am attching the pic for reference and also the code that I am using.
figure()
yyaxis left
plot(rad,Br_3_fem_ss,'color',[1,0,0])
ylim([-0.6 0.6])
ylabel('Brad');
yyaxis right
plot(rad1,Cur_3_fem_lam_ss,'color',[0,0,1])
ylim([-5e5 5e5])
ylabel('Current density');
grid on
xlim([0 pi])
xticks(0:(pi/18):pi)
legend('Brad','current den','Location','SouthWest')
title('Plot for Brad at 3 for Laminated rotor');
xlabel('Angle (rad)');
set(gcf,'Color','w');
set(gca,'fontname','times');
Accepted Answer
More Answers (1)
Walter Roberson
on 24 Feb 2026 at 7:36
0 votes
ylim is working for both sides.
However, the left side is not labeling the top end of the axes. You are not using yticks so there is no promise that the end of the range will happen to get labeled.
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!