![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/178295/image.png)
How can you nicely format box plots spread unevenly across the x axis?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Laurence hutton-smith
el 2 de Sept. de 2015
Comentada: Laurence hutton-smith
el 5 de Sept. de 2015
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148673/image.png)
0 comentarios
Respuesta aceptada
Cam Salzberger
el 4 de Sept. de 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/178295/image.png)
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!