필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
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 CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by