MATLAB: How to set the limits on the secondary y axis

limitssecondary axis

I would like to force my secondary Y axis to start from 0 rather than from 1.
figure('Position',[200, 200, 850, 400]);
yyaxis left
xlim([1 12])
P_8_area = area(ts,P_8,'EdgeColor','none');
P_8_area.FaceColor = ('k');
set(gca,'Color',[0.9 0.9 0.9]);
alpha(0.4)
xlabel('Time step')
ylabel('Power [kW]')
yyaxis right
Perm_1_8_plot = plot(ts,Perm_1_8,'-go','LineWidth',2);
xlabel('Time step')
ylabel('Permeate flow [m^3/h]')
hold on
yyaxis right
Perm_2_8_plot = plot(ts,Perm_2_8,'-r*','LineWidth',2);
xlabel('Time step')
ylabel('Permeate flow [m^3/h]')
yyaxis right
Perm_sw_8_plot = plot(ts,Perm_sw_8,'-b+','LineWidth',2);
xlabel('Time step')
ylabel('Permeate flow [m^3/h]')
legend([P_8_area,Perm_sw_8_plot,Perm_2_8_plot,Perm_1_8_plot],'Power',...
'Permeate flow with switching', 'Permeate flow 2 vessels','Permeate flow 1 vessel','Location','southwest')
hold off

Best Answer

Use ylim right after yyaxis right.