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

Skip to content

Commit 3883fa0

Browse files
committed
Use atleast_1d instead of redefining it.
1 parent d17d6b5 commit 3883fa0

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,20 +1997,14 @@ def bar(self, left, height, width=0.8, bottom=None, **kwargs):
19971997
label = kwargs.pop('label', '')
19981998
tick_labels = kwargs.pop('tick_label', None)
19991999

2000-
def make_iterable(x):
2001-
if not iterable(x):
2002-
return [x]
2003-
else:
2004-
return x
2005-
20062000
# make them safe to take len() of
20072001
_left = left
2008-
left = make_iterable(left)
2009-
height = make_iterable(height)
2010-
width = make_iterable(width)
2002+
left = np.atleast_1d(left)
2003+
height = np.atleast_1d(height)
2004+
width = np.atleast_1d(width)
20112005
_bottom = bottom
2012-
bottom = make_iterable(bottom)
2013-
linewidth = make_iterable(linewidth)
2006+
bottom = np.atleast_1d(bottom)
2007+
linewidth = np.atleast_1d(linewidth)
20142008

20152009
adjust_ylim = False
20162010
adjust_xlim = False
@@ -2186,9 +2180,7 @@ def make_iterable(x):
21862180
self.add_container(bar_container)
21872181

21882182
if tick_labels is not None:
2189-
tick_labels = make_iterable(tick_labels)
2190-
if isinstance(tick_labels, six.string_types):
2191-
tick_labels = [tick_labels]
2183+
tick_labels = np.atleast_1d(tick_labels)
21922184
if len(tick_labels) == 1:
21932185
tick_labels *= nbars
21942186
if len(tick_labels) != nbars:

0 commit comments

Comments
 (0)