Skip to content

Commit 2cec8c2

Browse files
authored
Merge pull request #6766 from tacaswell/sty_bxp_zorder
STY: set all artists in boxplots to same zorder
2 parents 70e7a6c + 297945c commit 2cec8c2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/matplotlib/axes/_axes.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -3551,6 +3551,8 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
35513551
'dotted': ':'
35523552
}
35533553

3554+
zorder = mlines.Line2D.zorder
3555+
zdelta = 0.1
35543556
# box properties
35553557
if patch_artist:
35563558
final_boxprops = dict(
@@ -3567,6 +3569,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
35673569
color=rcParams['boxplot.boxprops.color'],
35683570
)
35693571

3572+
final_boxprops['zorder'] = zorder
35703573
if boxprops is not None:
35713574
final_boxprops.update(boxprops)
35723575

@@ -3583,9 +3586,11 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
35833586
color=rcParams['boxplot.capprops.color'],
35843587
)
35853588

3589+
final_capprops['zorder'] = zorder
35863590
if capprops is not None:
35873591
final_capprops.update(capprops)
35883592

3593+
final_whiskerprops['zorder'] = zorder
35893594
if whiskerprops is not None:
35903595
final_whiskerprops.update(whiskerprops)
35913596

@@ -3600,6 +3605,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
36003605
markersize=rcParams['boxplot.flierprops.markersize'],
36013606
)
36023607

3608+
final_flierprops['zorder'] = zorder
36033609
# flier (outlier) properties
36043610
if flierprops is not None:
36053611
final_flierprops.update(flierprops)
@@ -3610,6 +3616,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
36103616
linewidth=rcParams['boxplot.medianprops.linewidth'],
36113617
color=rcParams['boxplot.medianprops.color'],
36123618
)
3619+
final_medianprops['zorder'] = zorder + zdelta
36133620
if medianprops is not None:
36143621
final_medianprops.update(medianprops)
36153622

@@ -3628,13 +3635,14 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
36283635
markeredgecolor=rcParams['boxplot.meanprops.markeredgecolor'],
36293636
markersize=rcParams['boxplot.meanprops.markersize'],
36303637
)
3638+
final_meanprops['zorder'] = zorder + zdelta
36313639
if meanprops is not None:
36323640
final_meanprops.update(meanprops)
36333641

36343642
def to_vc(xs, ys):
36353643
# convert arguments to verts and codes
36363644
verts = []
3637-
#codes = []
3645+
36383646
for xi, yi in zip(xs, ys):
36393647
verts.append((xi, yi))
36403648
verts.append((0, 0)) # ignored

0 commit comments

Comments
 (0)