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

Skip to content

Commit bdfc2e7

Browse files
committed
Made changes concise according to suggestion
1 parent fd45352 commit bdfc2e7

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

lib/matplotlib/axes/_axes.py

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

7214-
if 'hatch' in kwargs:
7215-
if not isinstance(kwargs['hatch'], str):
7216-
hatches = itertools.cycle(kwargs['hatch'])
7217-
else:
7218-
hatches = itertools.cycle([kwargs['hatch']])
7219-
7220-
if 'edgecolor' in kwargs:
7221-
if not isinstance(kwargs['edgecolor'], str):
7222-
edgecolors = itertools.cycle(kwargs['edgecolor'])
7223-
else:
7224-
edgecolors = itertools.cycle([kwargs['edgecolor']])
7225-
7226-
if 'linewidth' in kwargs:
7227-
if isinstance(kwargs['linewidth'], list or tuple):
7228-
linewidths = itertools.cycle(kwargs['linewidth'])
7229-
else:
7230-
linewidths = itertools.cycle([kwargs['linewidth']])
7214+
hatches = itertools.cycle(np.atleast_1d(kwargs.get('hatch', None)))
7215+
edgecolors = itertools.cycle(np.atleast_1d(kwargs.get('edgecolor', None)))
7216+
linewidths = itertools.cycle(np.atleast_1d(kwargs.get('linewidth', None)))
7217+
linestyles = itertools.cycle(np.atleast_1d(kwargs.get('linestyle', None)))
72317218

72327219
for patch, lbl in itertools.zip_longest(patches, labels):
72337220
if patch:
72347221
p = patch[0]
7235-
if 'hatch' in kwargs:
7236-
kwargs['hatch'] = next(hatches)
72377222
if 'edgecolor' in kwargs:
72387223
kwargs['edgecolor'] = next(edgecolors)
7239-
if 'linewidth' in kwargs:
7240-
kwargs['linewidth'] = next(linewidths)
7224+
kwargs.update({
7225+
'hatch': next(hatches),
7226+
'linewidth': next(linewidths),
7227+
'linestyle': next(linestyles),
7228+
})
72417229
p._internal_update(kwargs)
72427230
if lbl is not None:
72437231
p.set_label(lbl)

0 commit comments

Comments
 (0)