Can boxchart create a box plot with grid lines behind the boxes?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm trying to use boxchart create a box plot with y-axis grid lines. Obviously, I want the grid lines positioned behind the boxes, as they are for bars in a bar chart. But they appear in front of the boxes -- very unsightly. It seems this is due to the default alpha (0.2) for the box face color. So, I tried setting alpha to 1. The problem then is that the box edges and median lines are lost -- also unsightly. I'd like to set the box line or edge, but there are no such properties for boxchart. So, I'm stuck with the last chart below. Any suggestions on how to create a box plot like the second chart below, except with the grid lines behind the boxes?
y = randi(100,25,2);
clr = [.7 .85 .9];
tiledlayout('flow');
nexttile;
bar(mean(y), 'facecolor', clr);
ax = gca;
ax.YGrid = 'on';
nexttile;
boxchart(y);
ax = gca;
ax.YGrid = 'on';
nexttile;
boxchart(y, 'boxfacecolor', clr);
ax = gca;
ax.YGrid = 'on';
nexttile;
b = boxchart(y, 'boxfacecolor', clr, 'boxfacealpha', 1);
ax = gca;
ax.YGrid = 'on';
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!