Remove exponent from plot axis label

59 ビュー (過去 30 日間)
Jay Griffiths
Jay Griffiths 2023 年 6 月 21 日
編集済み: Angelo Yeo 2023 年 6 月 22 日
Hi, all.
I'm trying to remove the scientific format from my Y-axis label for my plot in MATLAB R2020a shown below.
I've tried everything I can find but, for the life of me, I cannot seem to get the Y-axis labels to display 10, 100, etc. instead of 10^1, 10^2, etc.
My plot code is as follows:
figure; semilogy(Pos, TC1, Pos, TC2, Pos, TC4, Pos, TC16)
legend('1C', '2C', '4C', '16C')
xlabel('Air Sample Position')
ylabel('Temperature (^{o}C)')
title('Temperature vs Position')
grid on
ax = gca;
ax.YAxis.TickLabelFormat = '%.0f';
ax.YAxis.Scale = 'log';
ax.YAxis.ExponentMode = 'manual';
ax.YAxis.Exponent = 0;
ax.YAxis.MinorTick = 'on';
Can anyone assist, please?
  2 件のコメント
Adam Danz
Adam Danz 2023 年 6 月 22 日
From the documentation: If the axis has a log scale, then the Exponent property has no effect.
Paul
Paul 2023 年 6 月 22 日
But the doc doesn't say anything about ignoring TickLabelFormat for a log scale, I don't believe, which is the property that I think the Question is really about. For a semilogy plot, the Y-TickLabelFormat is %g, even though that's not the format actually used for display
semilogy(1:100,1:100),grid,ax = gca;
ax.XAxis.TickLabelFormat
ans = '%g'
ax.YAxis.TickLabelFormat % YTickLabels display should be similar/same to XTickLabels?
ans = '%g'
I poked around trying to find something that overrides the %g format for the YAxis, but couldn't find it. Maybe just a gap in the doc?

サインインしてコメントする。

回答 (1 件)

Angelo Yeo
Angelo Yeo 2023 年 6 月 22 日
yticklabels(string(yticks))
  3 件のコメント
Jay Griffiths
Jay Griffiths 2023 年 6 月 22 日
Thank you. I tried both of these approaches but it seems to just label every tick with '100', even when I change the tick values to [1 10 100].
Using a log scale, is it simply not possible? I was able to achieve the desired plot in Excel but I prefer the aesthetic of MATLAB plots.
Angelo Yeo
Angelo Yeo 2023 年 6 月 22 日
編集済み: Angelo Yeo 2023 年 6 月 22 日
I don't understand why you run into such an issue. Please see the code below.
Pos = 1:7;
TC1 = [20, 200, 350, 500, 350, 200, 20];
figure; semilogy(Pos, TC1)
legend('1C')
xlabel('Air Sample Position')
ylabel('Temperature (^{o}C)')
title('Temperature vs Position')
grid on
yticklabels(yticks)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by