how to plot group box-lot with use of function multiple box-lot

1 回表示 (過去 30 日間)
shagun chaudhary
shagun chaudhary 2022 年 10 月 20 日
コメント済み: shagun chaudhary 2022 年 10 月 20 日
hi,
I have to make group boxplot into group 1 and 2. I am using function mutiple boxplot , but error is showing me undefined function of multiple_boxplot. I dont where i am going wrong, is this because of the matlab version. Please if somebody can help me in resolving this problem.
Thanks
x1=e.X1;
x2=e.X2;
X=[x1,x2];
y1=e.Y1;
y2=e.Y2;
Y=[y1,y2];
data = [X,Y]
data=cell(2,2);
for ii=1:size(data,1)
Xc{ii}=X(:,ii);
Yc{ii}=Y(:,ii);
end
data=vertcat(Xc,Yc);
xlab={'TSS','TP'};
multiple_boxplot(data',xlab,{'Malvern','Carling street'});
color = ['c', 'y', 'c', 'y'];
h = findobj(gca,'Tag','Box');
for j=1:length(h)
patch(get(h(j),'XData'),get(h(j),'YData'),color(j),'FaceAlpha',.5);
end
c = get(gca, 'Children');
hleg1 = legend(c(1:2);
data =
47.2925 17.8000 2.5930 0.4560
98.9950 41.0000 6.5235 1.8600
247.6635 8.3940 10.2760 4.9480
Unrecognized function or variable 'multiple_boxplot'.

採用された回答

the cyclist
the cyclist 2022 年 10 月 20 日
multiple_boxplot is not built in to MATLAB. It looks like it is a user-contributed functoin that you can download from the File Exchange here.
  7 件のコメント
the cyclist
the cyclist 2022 年 10 月 20 日
I see now that your code tries to mimic the syntax in the example on the FEX. That example works, but it is terrible code for a few reasons. I think I have made a better example below, but tried to keep close to the example, so it is not too confusing for you. (The code could be much cleaner if rewritten from scratch.)
% Pulling data from your online file. You can use your local file.
e = readtable("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1163403/data.xlsx");
x1=e.X1;
x2=e.X2;
X=[x1,x2];
y1=e.Y1;
y2=e.Y2;
Y=[y1,y2];
z1=e.Z1;
z2=e.Z2;
Z=[z1,z2];
data=cell(2,3); % This variable is weirdly used only to get the dimension, and then overwritten later??? Would have been better to get from X directly.
for ii=1:size(data,1)
Xc{ii}=X(:,ii);
Yc{ii}=Y(:,ii);
Zc{ii}=Z(:,ii);
end
data=vertcat(Xc,Yc,Zc);
xtickLabels={'Data column 1','Data column 2'};
legendLabel = {'X','Y','Z'};
figure
multiple_boxplot(data',xtickLabels,{'X','Y','Z'});
shagun chaudhary
shagun chaudhary 2022 年 10 月 20 日
Thank you so much . It been a great help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by