boxplot change X-Axis

140 ビュー (過去 30 日間)
Marco
Marco 2022 年 1 月 29 日
コメント済み: Marco 2022 年 1 月 29 日
Helllo,
I would like to plot a data set in several boxplots and display the median curve. Each data set has an X-value. In order to display the progression correctly, I would also like to display the distance between the values on the X-axis correctly, i.e. the distance between 100 and 300 should be correspondingly smaller than that between 300 and 1000. However, if I solve it as in the short example below, the X-values are only labels and the distances between two boxes are always the same, so that my progression is displayed distorted.
Is there a way to display this accordingly? Thank you!
y = [10 9 6 ; 9 8 7; 7 5 4]
x = [100 300 1000]
median = median(y);
boxplot(y, x)
hold on
plot(median, 'b','Marker','o')
hold off

採用された回答

Voss
Voss 2022 年 1 月 29 日
編集済み: Voss 2022 年 1 月 29 日
You can use the 'Positions' argument to boxplot(), see below. (I also changed your variable "median" to be "my_median" so it doesn't conflict with the function medan() when you try to run this same code again (if it is a script).)
y = [10 9 6 ; 9 8 7; 7 5 4]
y = 3×3
10 9 6 9 8 7 7 5 4
x = [100 300 1000]
x = 1×3
100 300 1000
my_median = median(y);
boxplot(y, x, 'Positions',x)
hold on
plot(x,my_median, 'b','Marker','o')
hold off
  1 件のコメント
Marco
Marco 2022 年 1 月 29 日
Thank you! That`s exactly what I was looking for.

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

その他の回答 (0 件)

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by