How to force matlab in a loop to always give you scientific/exponential notation?

1 回表示 (過去 30 日間)
Kim Arnold
Kim Arnold 2021 年 7 月 29 日
回答済み: Jan 2021 年 7 月 29 日
I want to do a for loop to produce several plots with subplots. On y-axis I always have absolute Signal intensity. For some of the graphs matlab uses then exponential notation, for others it uses for example numbers like 20000. Since I dont want to have a fix number in the exponential notation I cannot use for example
ax.YAxis.Exponent=3
because for the aformentioned number it gives me then 20 x 10^3 where I would prefer 2 x 10^4. I want that Matlab does the adjustment of the exponent automatically based on the max number on the y-axis. Does someone know how to force Matlab to use always use exponential notation?

回答 (1 件)

Jan
Jan 2021 年 7 月 29 日
What about:
ax = axes;
plot(1:10);
drawnow;
ax.YAxis.Exponent = ceil(log10(max(ax.YAxis.Limits)));

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by