Adding Exponent e.g. 10^_10 to Y Axis (normal code for this doesn't work.)

I simply want to change the y-labels on the y axis of my figure from positive to negative.
However, when I try to do this, using this code,
yticklabels = yticklabels % this just saves yticklabels as a variable.
yticklabels_append = append('-',yticklabels) % stick a negative in front of the yticklabels variable and save as yticklabels_append
% at this point, I clear the variable yticklabels. We only need yticklabels_append.
yticklabels(yticklabels_append) % re-assign the yticklabels of the graph to be the one with negatives
Here is the result applied to a figure.
If I run te code above, it indeed puts the minus sign in front of the y tick labels, but watch what happens.
The exponent is deleted...
Does anyone know how to get around this?
Yes, I've already tried this code:
ax.YAxis(2).Exponent=-10; % doesnt work
But it has no effect.

 採用された回答

Stephen23
Stephen23 2023 年 4 月 5 日
編集済み: Stephen23 2023 年 4 月 5 日

1 件のコメント

Mahir Mohammed
Mahir Mohammed 2023 年 4 月 5 日
Steve thank you ! You've saved me so much time !

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

その他の回答 (0 件)

カテゴリ

製品

リリース

R2019b

質問済み:

2023 年 4 月 5 日

編集済み:

2023 年 4 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by