How do i prevent boxplots from overlapping in a for loop?
Show older comments
Dear all,
I am using a for-loop to plot different boxplots of a certain group but with slightly different values. WHen running the loop, the different boxes are plotted on top of each other in stead of next to each other. I would like to have a plot with for each class (8 classes) the five different boxplots calculated by the for loop next to each other, so in total 40 boxplots grouped per 5 next to each other.
Does anyone have an idea on how to do this?
%% Plot Tb in function of salinity for multiple vegetation classes
% Horizontal Polarization
fig_box_Tbh_veg = figure;
index=1;
Mh=zeros(length(s_list),length(lai_list)*length(veg_cls_list));
for veg_cls = veg_cls_list
param=extract_lookup_RTMparam(option,veg_cls,soil_cls,inc);
for lai=lai_list
data={};
for s = s_list
[Tbh,Tbv,c_er] = RTM_forward(opt, rtmv, T5, lai, Tc, tair, param,s,t);
data{end+1,1}= veg_cls;
data{end,2}=s;
data{end,3}=Tbh;
data{end,4}=Tbv;
data{end,5}=c_er;
end
table=cell2table(data,'VariableNames',{'Vegetation_class','Salinity','Tb_horizontal','Tb_vertical','dielectric_constant'});
disp(table);
Mh(:,index)=table.Tb_horizontal;
index=index+1;
end
end
boxplot(Mh);
xlabel('Vegetation type');
ylabel('Tb Horizontal polarization');
hold off
Accepted Answer
More Answers (0)
Categories
Find more on 3-D Function Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!