Move positive and negative y ticks in plot in alignment
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
DavidL88
le 21 Juil 2022
Commenté : Star Strider
le 22 Juil 2022
In my plot below I want to align the yticks to the right so that the numbers are aligned vertically. The -3 and -6 are closer to the axis line as they have a minus first whereas the 0, 3 and 6 have a space after them. I tried putting a space prior to these three digits so the numbers are aligned but didn't work. Is there a way to do this or make these ticks alig to the right rather than left?
ylim([-6.3 6.3])
yticks([-6 -3 0 3 6]);
0 commentaires
Réponse acceptée
Star Strider
le 21 Juil 2022
figure
plot(1:10, randn(1,10))
ylim([-6.3 6.3])
yticks([-6 -3 0 3 6]);
Ax = gca;
Ax.YAxis.TickLabelFormat = '%3.0f';
.
6 commentaires
Star Strider
le 22 Juil 2022
My pleasure!
That was essentially my original approach. There are several ways to set the tick format, and I chose one that I was certain would work.
If my Answer helped you solve your problem, please Accept it!
.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!