Axis exponent not displaying when changing TickLabels
Afficher commentaires plus anciens
Hi everyone, and thanks in advance.
I'm currently using Matlab 2019b and 2020a.
The problem I have is that I can't forze Matlab to show the exponent I want for a given axis and select the TickLabels at the same time.
The problem seems to come from the fact that once I set the TickLabelMode to 'manual' or write the TickLabels myself, the exponent just stops showing (even though it keeps it's value)
For example, if I run:
X = 1:10;
Y = linspace(1, 10e4, 10);
figure()
plot(X,Y)
ejes = gca;
ejes.YTick = [0, 2.5e4, 5e4, 7.5e4, 10e4];
Then I get:

With an exponent of '4', as desired.
The problem is, once I set the TickLabels myself, it disappears (even if I change them to the same ones). For example:
DefaultLabels = ejes.YTickLabel;
ejes.YTickLabel = DefaultLabels;
Outputs:

The problem is I am writting a paper in Spanish, so I need to change the dots to commas in the numbers, whic I can do using:
ejes.YTickLabel = replace(ejes.YTickLabel, {'.', ','}, {',', '.'});
which gives me the desired number format but without any exponent:

Is there any work around or any way to forze matlab to display the exponent?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Labels and Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!