Can boxchart create a box plot with grid lines behind the boxes?
8 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Distribution Plots についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!