Axis exponent not displaying when changing TickLabels
6 views (last 30 days)
Show older comments
Jaime López
on 21 May 2020
Answered: Walter Roberson
on 21 May 2020
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/296738/image.png)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/296743/image.png)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/296748/image.png)
Is there any work around or any way to forze matlab to display the exponent?
0 Comments
Accepted Answer
Walter Roberson
on 21 May 2020
Unfortunately that is automatic, the exponent is shut off when manual tick labels are used. You would need to text() the exponent into place.
There are some places in MATLAB that provide for automatic use of other decimal seperators, but unfortunately text() is not one of them at this time.
0 Comments
More Answers (0)
See Also
Categories
Find more on Formatting and Annotation 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!