Boxplot with logarithmic y-axis

28 ビュー (過去 30 日間)
Tim Jahn
Tim Jahn 2020 年 9 月 3 日
編集済み: Cris LaPierre 2020 年 9 月 8 日
I want to have a boxplot with logarithmic scale on the y-axis (similiar to the semilogy command for plot). I have not yet found a good solution. So far I transformed my data before creating the plot with the log() function, and afterwards I used the normal boxplot command. The plot itself looks nice then, but the y-axis is wrongly scaled. The y-range lies between -5 and -2, but I want to have exp(-5) to exp(-2). Is there a way to take the exponential of the whole axis? As a rather poor solution, I manually set the y-tick to [-5 -4 -3 -2] and then the yticklabel to {'exp(-5)',...,'exp(-2)'}, but this is for sure not an elegant solution.

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 9 月 4 日
編集済み: Cris LaPierre 2020 年 9 月 8 日
The tick values must correspond to the plotted data. The tick labels can be whatever you want.
You can change the scale of your Y axis. Have you tried setting it to log?
ax = gca;
ax.YAxis.Scale ="log";
  1 件のコメント
Tim Jahn
Tim Jahn 2020 年 9 月 7 日
Thank you Cris, this worked!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by