HI,
with r2020 there is finally a grouped boxplot called "boxchart". However. I don't seem to get the structure and options of it. Multiple questions.
How does one apply any property simultaneously to all boxes instead of looping? For instance like b.Notch = 'on' or a colormap to the ColorGroup? The standard colors especially their order is not what I'm looking for. however, assigning a colormap doesn't work, nor can I apply a b=boxchart()… b.BoxFaceColor = parula(size(b,1)) with n-colors for n-Groups. What am I not seeing here? All I can do is loop over all.
cols = parula(size(b,1));for i = 1:size(b,1) bb(i).BoxFaceColor = cols(i,:);end% this seems extremely cumbersome
here I have looped over each bb(i) as shown above in order to apply a colr map of my choice. .
Another question that pops up: How could I add separation lines? In the example image above I have added them with an image editor.. obviously not the choice!
Next: Why can't I seem to get a correct looking diagram when plotting when input xGroupData are unique numbers of discrete groups.. The diagram's x-axis or x-grouping is then entirely messed up.
xgroupdata = repmat([0, 0.0125, 0.0250, 0.0375], [1,100]);ydata = rand(size(xgroupdata));group = datasample(1:1:5,size(xgroupdata,2));figure;boxchart(xgroupdata,ydata, 'GroupByColor', group);legend;
here is what that code produces. Only Group3 seems to be correctly placed at the proper xgroup-values. But the automatic box-width, doesn't work and the group spacing is also totally messed up, seems to be 0.2 but I can't even find a property in boxchart's documentation
I would like to be able to add a textlabel to any of the boxes with the sample size. For this I need to a) figure out the position of the boxes but I don't manage to understand the structure of the handle… there are zero Children for instance…
Best Answer