Axis exponent not displaying when changing TickLabels

6 次查看(过去 30 天)
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?

采纳的回答

Walter Roberson
Walter Roberson 2020-5-21
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 个)

类别

Help CenterFile Exchange 中查找有关 Formatting and Annotation 的更多信息

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by