I want to change the 2D graph by changing the configuration of Boxplot.

2 ビュー (過去 30 日間)
inseong Hwang
inseong Hwang 2021 年 4 月 20 日
回答済み: Jonas 2021 年 4 月 21 日
Hello.
Using Matlab's Boxplot function, a box graph with values of Max, Min, 25%, Median, and 75% is drawn.
I would like to change this to a box graph consisting of Max, Min, Mean-Standard Deviation, Mean, and Mean + Standard Deviation.
  1 件のコメント
Jonas
Jonas 2021 年 4 月 20 日
編集済み: Jonas 2021 年 4 月 20 日
you can try to change the values inside the boxplot function. open the function using
edit boxplot
and search for quantiles, i think they were named q25 or similarly. good luck, boxplot is a really ugly function to change. it would be easier if you just want to add the information you asked for

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

採用された回答

Jonas
Jonas 2021 年 4 月 21 日
so here the way i went so far: i change just the properties of the image, at the moment the code changes the median line to mean and the boxes to mean+std and mean-std. at the moment it leaves the whiskers (lines to min or max) unchanged, you should change it accordingly: i give you an example, you should be able to change it according to your wishes
clear
close all;
rng('default');
% generate some data
nrOfBoxes=4;
a=randi(5,9,nrOfBoxes);
boxplot(a);
% get lines from axis
bxpltAx=gca;
lines=bxpltAx.Children.Children;
% In the boxplot objects the objects are ordered for boxes from right to left
lines=flip(lines);
% make clear which line object is which (did not test all of them)
upperWhiskers=lines(1:nrOfBoxes);
lowerWhiskers=lines((1:nrOfBoxes)+1*nrOfBoxes);
maximums=lines((1:nrOfBoxes)+2*nrOfBoxes);
minimums=lines((1:nrOfBoxes)+3*nrOfBoxes);
boxes=lines((1:nrOfBoxes)+4*nrOfBoxes); % Corner YData and XData: left bot, left top, right top, right bot; pairwise line coordinates!
medians=lines((1:nrOfBoxes)+5*nrOfBoxes);
outliers=lines((1:nrOfBoxes)+6*nrOfBoxes);
% data you asked for calculated column-wise
means=mean(a);
stds=std(a);
for boxNr=1:nrOfBoxes
% set medians to means
medians(boxNr).YData=[means(boxNr) means(boxNr)];
% calculate new bounds
newUpperBound=means(boxNr)+stds(boxNr);
newLowerBound=means(boxNr)-stds(boxNr);
% set box bounds to mean+std and mean-std
boxes(boxNr).YData([2 3])=newUpperBound;
boxes(boxNr).YData([1 4 5])=newLowerBound;
end

その他の回答 (1 件)

inseong Hwang
inseong Hwang 2021 年 4 月 21 日
Thank you.
Boxplot conversion is too difficult for me as I am immature with function changes.
Could you help me a little more?
p25 = means-standard deviation
p50 = mean
p75 = mean + standard deviation
I want to change p75 to Mean + standard deviation.

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by