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

Skip to content

Commit c2fff54

Browse files
committed
MNT : simplified handling of wrong number of labels
instead of padding length of labels by hand, use `zip_longest`
1 parent a22e82e commit c2fff54

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
unicode_literals)
33

44
import six
5-
from six.moves import reduce, xrange, zip
5+
from six.moves import reduce, xrange, zip, zip_longest
66

77
import math
88
import warnings
9-
import itertools
109

1110
import numpy as np
1211
from numpy import ma
@@ -5856,10 +5855,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
58565855
else:
58575856
labels = [str(lab) for lab in label]
58585857

5859-
if len(labels) < nx:
5860-
labels += [None] * (nx - len(labels))
5861-
5862-
for (patch, lbl) in zip(patches, labels):
5858+
for (patch, lbl) in zip_longest(patches, labels, fillvalue=None):
58635859
if patch:
58645860
p = patch[0]
58655861
p.update(kwargs)

0 commit comments

Comments
 (0)