The farthest yticklabels do not appear when using ax.YAxisLocation = 'origin'
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sim
el 24 de Jun. de 2024
Comentada: Les Beckham
el 25 de Jun. de 2024
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 comentarios
Respuesta aceptada
Les Beckham
el 24 de Jun. de 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])
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Axis Labels en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!