Skip to content

Commit e3265a1

Browse files
tacaswellstory645
authored andcommitted
STY: set all artists in boxplots to same zorder
Add a small delta to the mean and median lines to ensure that they are on top. closes #6510
1 parent 7920f0d commit e3265a1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3553,6 +3553,8 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
35533553
'dotted': ':'
35543554
}
35553555

3556+
zorder = mlines.Line2D.zorder
3557+
zdelta = 0.1
35563558
# box properties
35573559
if patch_artist:
35583560
final_boxprops = dict(
@@ -3569,6 +3571,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
35693571
color=rcParams['boxplot.boxprops.color'],
35703572
)
35713573

3574+
final_boxprops['zorder'] = zorder
35723575
if boxprops is not None:
35733576
final_boxprops.update(boxprops)
35743577

@@ -3585,9 +3588,11 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
35853588
color=rcParams['boxplot.capprops.color'],
35863589
)
35873590

3591+
final_capprops['zorder'] = zorder
35883592
if capprops is not None:
35893593
final_capprops.update(capprops)
35903594

3595+
final_whiskerprops['zorder'] = zorder
35913596
if whiskerprops is not None:
35923597
final_whiskerprops.update(whiskerprops)
35933598

@@ -3602,6 +3607,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
36023607
markersize=rcParams['boxplot.flierprops.markersize'],
36033608
)
36043609

3610+
final_flierprops['zorder'] = zorder
36053611
# flier (outlier) properties
36063612
if flierprops is not None:
36073613
final_flierprops.update(flierprops)
@@ -3612,6 +3618,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
36123618
linewidth=rcParams['boxplot.medianprops.linewidth'],
36133619
color=rcParams['boxplot.medianprops.color'],
36143620
)
3621+
final_medianprops['zorder'] = zorder + zdelta
36153622
if medianprops is not None:
36163623
final_medianprops.update(medianprops)
36173624

@@ -3630,13 +3637,14 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
36303637
markeredgecolor=rcParams['boxplot.meanprops.markeredgecolor'],
36313638
markersize=rcParams['boxplot.meanprops.markersize'],
36323639
)
3640+
final_meanprops['zorder'] = zorder + zdelta
36333641
if meanprops is not None:
36343642
final_meanprops.update(meanprops)
36353643

36363644
def to_vc(xs, ys):
36373645
# convert arguments to verts and codes
36383646
verts = []
3639-
#codes = []
3647+
36403648
for xi, yi in zip(xs, ys):
36413649
verts.append((xi, yi))
36423650
verts.append((0, 0)) # ignored

0 commit comments

Comments
 (0)