Skip to content

Commit af43359

Browse files
committed
FIX: single label per boxplot
1 parent db5fe9a commit af43359

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4004,9 +4004,6 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
40044004
if 'color' in boxprops:
40054005
boxprops['edgecolor'] = boxprops.pop('color')
40064006

4007-
if labels:
4008-
boxprops['label'] = labels
4009-
40104007
# if non-default sym value, put it into the flier dictionary
40114008
# the logic for providing the default symbol ('b+') now lives
40124009
# in bxp in the initial value of flierkw
@@ -4280,6 +4277,7 @@ def do_patch(xs, ys, **kwargs):
42804277
capwidths):
42814278
# try to find a new label
42824279
datalabels.append(stats.get('label', pos))
4280+
box_kw['label'] = stats.get('label', None)
42834281

42844282
# whisker coords
42854283
whis_x = [pos, pos]

lib/matplotlib/tests/test_legend.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,3 +1465,13 @@ def test_boxplot_legend():
14651465
assert handle.get_facecolor() == colors[index]
14661466
assert handle.get_edgecolor() == colors[index]
14671467
assert handle.get_label() == labels[index]
1468+
1469+
1470+
def test_boxplot_multi_label():
1471+
# Smoke test that we can pass a 2D array and sequence of labels.
1472+
fig, ax = plt.subplots()
1473+
1474+
A = np.arange(30).reshape(10, 3)
1475+
labels = ['a', 'b', 'c']
1476+
1477+
ax.boxplot(A, labels=labels)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy