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

Skip to content

Commit ce563fd

Browse files
committed
Made changes concise according to suggestion
1 parent 2703b2b commit ce563fd

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7166,33 +7166,16 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
71667166
# cast each element to str, but keep a single str as it.
71677167
labels = [] if label is None else np.atleast_1d(np.asarray(label, str))
71687168

7169-
if 'hatch' in kwargs:
7170-
if not isinstance(kwargs['hatch'], str):
7171-
hatches = itertools.cycle(kwargs['hatch'])
7172-
else:
7173-
hatches = itertools.cycle([kwargs['hatch']])
7174-
7175-
if 'edgecolor' in kwargs:
7176-
if not isinstance(kwargs['edgecolor'], str):
7177-
edgecolors = itertools.cycle(kwargs['edgecolor'])
7178-
else:
7179-
edgecolors = itertools.cycle([kwargs['edgecolor']])
7180-
7181-
if 'linewidth' in kwargs:
7182-
if isinstance(kwargs['linewidth'], list or tuple):
7183-
linewidths = itertools.cycle(kwargs['linewidth'])
7184-
else:
7185-
linewidths = itertools.cycle([kwargs['linewidth']])
7169+
hatches = itertools.cycle(np.atleast_1d(kwargs.get('hatch', None)))
7170+
edgecolors = itertools.cycle(np.atleast_1d(kwargs.get('edgecolor', None)))
7171+
linewidths = itertools.cycle(np.atleast_1d(kwargs.get('linewidth', None)))
7172+
linestyles = itertools.cycle(np.atleast_1d(kwargs.get('linestyle', None)))
71867173

71877174
for patch, lbl in itertools.zip_longest(patches, labels):
71887175
if patch:
71897176
p = patch[0]
7190-
if 'hatch' in kwargs:
7191-
kwargs['hatch'] = next(hatches)
7192-
if 'edgecolor' in kwargs:
7193-
kwargs['edgecolor'] = next(edgecolors)
7194-
if 'linewidth' in kwargs:
7195-
kwargs['linewidth'] = next(linewidths)
7177+
kwargs = {'edgecolor': next(edgecolors), 'linewidth': next(linewidths),
7178+
'hatch': next(hatches), 'linestyle': next(linestyles)}
71967179
p._internal_update(kwargs)
71977180
if lbl is not None:
71987181
p.set_label(lbl)

0 commit comments

Comments
 (0)