Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 297945c

Browse files
committed
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 a61f763 commit 297945c

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
@@ -3537,6 +3537,8 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
35373537
'dotted': ':'
35383538
}
35393539

3540+
zorder = mlines.Line2D.zorder
3541+
zdelta = 0.1
35403542
# box properties
35413543
if patch_artist:
35423544
final_boxprops = dict(
@@ -3553,6 +3555,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
35533555
color=rcParams['boxplot.boxprops.color'],
35543556
)
35553557

3558+
final_boxprops['zorder'] = zorder
35563559
if boxprops is not None:
35573560
final_boxprops.update(boxprops)
35583561

@@ -3569,9 +3572,11 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
35693572
color=rcParams['boxplot.capprops.color'],
35703573
)
35713574

3575+
final_capprops['zorder'] = zorder
35723576
if capprops is not None:
35733577
final_capprops.update(capprops)
35743578

3579+
final_whiskerprops['zorder'] = zorder
35753580
if whiskerprops is not None:
35763581
final_whiskerprops.update(whiskerprops)
35773582

@@ -3586,6 +3591,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
35863591
markersize=rcParams['boxplot.flierprops.markersize'],
35873592
)
35883593

3594+
final_flierprops['zorder'] = zorder
35893595
# flier (outlier) properties
35903596
if flierprops is not None:
35913597
final_flierprops.update(flierprops)
@@ -3596,6 +3602,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
35963602
linewidth=rcParams['boxplot.medianprops.linewidth'],
35973603
color=rcParams['boxplot.medianprops.color'],
35983604
)
3605+
final_medianprops['zorder'] = zorder + zdelta
35993606
if medianprops is not None:
36003607
final_medianprops.update(medianprops)
36013608

@@ -3614,13 +3621,14 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
36143621
markeredgecolor=rcParams['boxplot.meanprops.markeredgecolor'],
36153622
markersize=rcParams['boxplot.meanprops.markersize'],
36163623
)
3624+
final_meanprops['zorder'] = zorder + zdelta
36173625
if meanprops is not None:
36183626
final_meanprops.update(meanprops)
36193627

36203628
def to_vc(xs, ys):
36213629
# convert arguments to verts and codes
36223630
verts = []
3623-
#codes = []
3631+
36243632
for xi, yi in zip(xs, ys):
36253633
verts.append((xi, yi))
36263634
verts.append((0, 0)) # ignored

0 commit comments

Comments
 (0)