How can you nicely format box plots spread unevenly across the x axis?

3 views (last 30 days)
Can anyone help me format this plot of several box plots in a more aesthetically pleasing way? What is going on near the origin is rather unclear. Also it has made the width of the later boxplots very thin, I have not been able to correct this.
I have attached the data points I am plotting, this graph was created using the following code
figure
boxplot(M,'positions',KD_values)

Accepted Answer

Cam Salzberger
Cam Salzberger on 4 Sep 2015
Hello Laurence,
I understand that you would like the box plot to be a little more easily viewed, both in box width and box spacing.
The former issue can be resolved by specifying the 'widths' argument in the boxplot function. Since there is a different amount of spacing between each line, it is probably best to specify the box widths differently for each data point based on that spacing (so long as it is understood that box width is not representing data differently).
The latter issue can be resolved by viewing the plot with a logarithmic scale on the x-axis. This will space out the data points more evenly, though there is now a little clustering in the higher valued regions.
KDgaps = diff(KD_values)/2;
boxplot(M,'positions',KD_values,'widths',[KDgaps(1) KDgaps])
set(gca,'XScale','log')
I hope this helps!
-Cam

More Answers (0)

Community Treasure Hunt

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

Start Hunting!