Hello,
I'm struggling with a weird effect of the new (R2020a) boxchart function. The latter is essentially the same thing as boxplot, but much nicer.
I used to produce boxplots, and adding significance stars from pvalue using the sigstar function from Rob Campbell. The stars and bars were nicely displayed (not too high, not too low, not interfering with data...). To get the good positions for the stars and bars, the strategy emploed is quite simple : make the axis tight, and zoom in the xaxis around the data. Since axis are set to tight, the y axis is automatically rescaled to match the min and max values of the displayed data. Extract the max value, add some offset, and everything is fine.
Now, when creating the boxplot with the boxchart function, and adding stars and bars with sigstar, the stars and bars are way too high.
After investigation, this is because after adjusting the x axis on a plot made with boxchart, the y axis is not automatically adjusted, even though the ax.YAxis.LimitsMode is set to 'auto', as if the internal algorithm used for adjusting axis still take into account the whole plot.
Any idea of why such behavior ? And any idea of a workaround ?
I would like to keep things simple. What I like with this method is that it is "graphic" exploiting the automatic features from Matlab, without the need to play around with the actual YData.
Cheers,
Guillaume
[Update] Here some code to reproduce the bug.
x = [1, 1, 2, 2, 3, 3];
y = [0.1, 0.15, 0.15, 0.2, 0.5, 0.8];
figure; boxplot(y, x);
xlim([0.9, 2.1]);
ylim auto
Produces : While
figure; boxchart(x, y);
xlim([0.9, 2.1]);
ylim auto
Produces :