Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 017f729

Browse filesBrowse files
authored
Merge pull request #26568 from meeseeksmachine/auto-backport-of-pr-26462-on-v3.8.x
Backport PR #26462 on branch v3.8.x (Boxplot fix median line extending past box boundaries #19409)
2 parents 8bcceb5 + 4ffe411 commit 017f729
Copy full SHA for 017f729

37 files changed

+21
-1
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4095,7 +4095,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
40954095
40964096
capwidths : float or array-like, default: None
40974097
Either a scalar or a vector and sets the width of each cap.
4098-
The default is ``0.5*(with of the box)``, see *widths*.
4098+
The default is ``0.5*(width of the box)``, see *widths*.
40994099
41004100
vert : bool, default: True
41014101
If `True` (default), makes the boxes vertical.
@@ -4147,6 +4147,17 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
41474147
--------
41484148
.. plot:: gallery/statistics/bxp.py
41494149
"""
4150+
# Clamp median line to edge of box by default.
4151+
medianprops = {
4152+
"solid_capstyle": "butt",
4153+
"dash_capstyle": "butt",
4154+
**(medianprops or {}),
4155+
}
4156+
meanprops = {
4157+
"solid_capstyle": "butt",
4158+
"dash_capstyle": "butt",
4159+
**(meanprops or {}),
4160+
}
41504161

41514162
# lists of artists to be output
41524163
whiskers = []
Binary file not shown.
Loading
Loading
Loading
Loading
Loading
Binary file not shown.
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3223,6 +3223,15 @@ def test_bxp_customwhisker():
32233223
whiskerprops=dict(linestyle='-', color='m', lw=3)))
32243224

32253225

3226+
@check_figures_equal()
3227+
def test_boxplot_median_bound_by_box(fig_test, fig_ref):
3228+
data = np.arange(3)
3229+
medianprops_test = {"linewidth": 12}
3230+
medianprops_ref = {**medianprops_test, "solid_capstyle": "butt"}
3231+
fig_test.subplots().boxplot(data, medianprops=medianprops_test)
3232+
fig_ref.subplots().boxplot(data, medianprops=medianprops_ref)
3233+
3234+
32263235
@image_comparison(['bxp_withnotch.png'],
32273236
remove_text=True,
32283237
savefig_kwarg={'dpi': 40},

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.