How to plot .mat files in boxplot?
이전 댓글 표시
Hello, I am trying to plot these three data files of mean fluorescence intensity from microscopy analyses and can't figure out how to plot three different data sets. I have only ever plotted control v. treatment. (I am still new to coding and don't have a strong background in computer science) This is my current code and error:
load Ter119WT.mat intensity
WT = intensity;
load Ter119P95H.mat intensity
P95H = intensity;
load Ter119P95Hrip.mat intensity
P95Hrip = intensity;
DATA = [WT;P95H;P95Hrip];
GROUP = [ones(size(WT));2*ones(size(P95H));3*ones(size(P95Hrip))];
figure
set(gcf,'color','w','units','inches','position',[1 1 4 4])
boxplot(DATA,GROUP)
set(gca,'ylim',[3000 9000], 'xticklabel',{'WT','P95H','P95HD'},'fontweight','bold','fontsize',11,...
'linewidth',1.5,'xcolor','k','ycolor','k');
set(findobj(gca,'Tag','Box'),'LineWidth',1.5);
lines = findobj(gcf, 'type', 'line', 'Tag', 'Median');
set(lines,'LineWidth',1.5);
set(findobj(gca,'Tag','Lower Whisker'),'Linewidth',1.5);
set(findobj(gca,'Tag','Upper Whisker'),'Linewidth',1.5);
set(findobj(gca,'Tag','Upper Adjacent Value'),'Linewidth',1.5);
set(findobj(gca,'Tag','Lower Adjacent Value'),'Linewidth',1.5);
답변 (1개)
You mention an error, but I'm not sure if you mean you got an error message or just that the plot is not what you expected. If you got an error message, post it and someone can figure out what's wrong. (It may also be useful if you upload your mat files, if that's feasible.)
In any case, here's how you can avoid using findobj, and instead set the lines' properties more directly (this uses random data where each data set is one column):
% load Ter119WT.mat intensity
% WT = intensity;
% load Ter119P95H.mat intensity
% P95H = intensity;
% load Ter119P95Hrip.mat intensity
% P95Hrip = intensity;
WT = 3000+6000*rand(100,1);
P95H = 3000+6000*rand(90,1);
P95Hrip = 3000+6000*rand(110,1);
DATA = [WT;P95H;P95Hrip];
GROUP = [ones(size(WT));2*ones(size(P95H));3*ones(size(P95Hrip))];
figure
set(gcf,'color','w','units','inches','position',[1 1 4 4])
h = boxplot(DATA,GROUP) % use the line handles returned from boxplot, here I call them "h"
reshape(get(h,'Tag'),size(h)) % check out the Tags to know what's what
set(gca,'ylim',[3000 9000], 'xticklabel',{'WT','P95H','P95HD'},'fontweight','bold','fontsize',11,...
'linewidth',1.5,'xcolor','k','ycolor','k');
% set(findobj(gca,'Tag','Box'),'LineWidth',1.5);
% lines = findobj(gcf, 'type', 'line', 'Tag', 'Median');
% set(lines,'LineWidth',1.5);
% set(findobj(gca,'Tag','Lower Whisker'),'Linewidth',1.5);
% set(findobj(gca,'Tag','Upper Whisker'),'Linewidth',1.5);
% set(findobj(gca,'Tag','Upper Adjacent Value'),'Linewidth',1.5);
% set(findobj(gca,'Tag','Lower Adjacent Value'),'Linewidth',1.5);
set(h(1:6,:),'LineWidth',1.5);
댓글 수: 4
Halee Scott
2022년 4월 14일
Voss
2022년 4월 14일
You're welcome!
Halee Scott
2022년 4월 14일
Voss
2022년 4월 14일
Can you upload the mat files?
카테고리
도움말 센터 및 File Exchange에서 Box Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
