Can boxchart create a box plot with grid lines behind the boxes?

9 Ansichten (letzte 30 Tage)
Scott MacKenzie
Scott MacKenzie am 20 Apr. 2021
Bearbeitet: Scott MacKenzie am 12 Mai 2021
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';

Antworten (0)

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by