I would like to change the ylim of the left yaxis. You can see that the ylim entry has no effect at all. I can only change the right side of the yyaxis plot. I appraciate your advice.
Best regards
%%figure
fig = figure (1);
set(fig, 'Units', 'normalized', 'Position', [0.2, 0.1, 0.5, 0.3]);
set(0,'defaulttextInterpreter','latex')
%%Plot data
%First subplot
ax1 = subplot(121)
x1 = linspace(1, 1000);
y11 = x1.^2;
y12 = x1;
yyaxis left
ylim([1, 100]); % Has no effect. Why?
plot(x1,y11,'LineWidth',1.5);
grid on
yyaxis right
plot(x1,y12,'LineWidth',1.5);
%Second subplot
ax2 = subplot(122);
plot(x1,exp(x1),'LineWidth',1.5);
grid on;

 Réponse acceptée

Walter Roberson
Walter Roberson le 23 Nov 2017

0 votes

3 commentaires

Henrik Schädlich
Henrik Schädlich le 23 Nov 2017
Modifié(e) : Henrik Schädlich le 23 Nov 2017
Thanks for the advice. I could read the limits of both axes in the variables YLL and YLR. But i could not change them. Do you know how to do that? There is not a proper solution on the page linked to that I can transform into my routine.
clear all
close all
%%figure
fig = figure (1);
set(fig, 'Units', 'normalized', 'Position', [0.2, 0.1, 0.5, 0.3]);
set(0,'defaulttextInterpreter','latex')
%%Plot data
%First subplot
ax1 = subplot(121)
x1 = linspace(1, 1000);
y11 = x1.^2;
y12 = x1;
yyaxis left
plot(x1,y11,'LineWidth',1.5);
yyaxis right
plot(x1,y12,'LineWidth',1.5);
YLL = ax1.YAxis(1).Limits %limits of left side
YLR = ax1.YAxis(2).Limits %limits of right side
hAxes(1).YAxis(1).Limits = ([0, 100]); % change limits of left side
% doesn't work
%Second subplot
ax2 = subplot(122);
plot(x1,exp(x1),'LineWidth',1.5);
grid on;
ax1.YAxis(1).Limits = ([0, 100]); % change limits of left side
Henrik Schädlich
Henrik Schädlich le 24 Nov 2017
Of course. I placed the wrong variable. ^^ Thank you.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by