How to change x-axis to not use scientific notation

28 ビュー (過去 30 日間)
Haojue Yu
Haojue Yu 2021 年 10 月 29 日
コメント済み: Star Strider 2021 年 10 月 29 日
I want to display x-axis as 1, 10, 100, and not as 10^0, 10^1...
I tried the code:
ax = gca;
ax.XAxis.Exponent = 0;
But it doesn't work, and I also tried:
curtick = get(gca, 'XTick');
set(gca, 'XTickLabel', cellstr(num2str(curtick(:))));
But the x-axis looks wierd, and instead of being 1, 10, 100, 1000, it keeps repeating 1, 100, 1, 100

採用された回答

Star Strider
Star Strider 2021 年 10 月 29 日
I have no idea what the problem is, because the posted code works correctly here and on my computer (R2021b) —
x = logspace(0, 3, 5);
y = rand(size(x))*4.5;
figure
semilogx(x, y, 'p')
curtick = get(gca, 'XTick');
set(gca, 'XTickLabel', cellstr(num2str(curtick(:))));
figure
scatter(x, y, 150, 'g', 'p', 'filled')
ax = gca;
ax.XScale = 'log';
curtick = ax.XTick;
set(gca, 'XTickLabel', cellstr(num2str(curtick(:))));
It works here.
.
  4 件のコメント
Haojue Yu
Haojue Yu 2021 年 10 月 29 日
Thank you so much, I will check it out, and the last line of code work.
Star Strider
Star Strider 2021 年 10 月 29 日
As always, my pleasure!
.

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by