The farthest yticklabels do not appear when using ax.YAxisLocation = 'origin'
2 views (last 30 days)
Show older comments
The two farthest ytickslabels (in this case both -1 and +1), do not show up if I use ax.YAxisLocation = 'origin'
x=-1:0.1:1;
plot(x,x,'o-')
ax=gca;
ax.YAxisLocation = 'origin';
set(ax,'fontsize',20)
yticks([-1 -0.5 0 0.5 1])
Is there a way to show them without playing with ylim([-2 2]) as here below?
x=-1:0.1:1;
plot(x,x,'o-')
ax=gca;
ax.YAxisLocation = 'origin';
set(ax,'fontsize',20)
yticks([-1 -0.5 0 0.5 1])
ylim([-2 2])
0 Comments
Accepted Answer
Les Beckham
on 24 Jun 2024
I'm not sure this is much more satisfactory than your approach, but it appears to at least work and would adapt to different y axis ranges.
It's interesting that the 'ylimitmethod' and 'xlimitmethod' work differently for their default values of 'tickaligned'. Maybe because the x labels are outside the axis and thus have more room to be displayed.
x=-1:0.1:1;
plot(x,x,'o-')
grid on
ax=gca;
ax.YAxisLocation = 'origin';
set(ax,'fontsize',20)
yticks([-1 -0.5 0 0.5 1])
set(gca, 'ylimitmethod', 'padded')
% ylim([-2 2])
More Answers (0)
See Also
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!