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:
![](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 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Formatting and Annotation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!