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

Skip to content

Commit ddad973

Browse files
committed
Minor style-ish changes in _process_plot_var_args.
- Swap arguments on _getdefaults so that ignores can be made optional. - Inline some temporaries, and use more comprehensions.
1 parent 5e8f2b8 commit ddad973

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def get_next_color(self):
311311
else:
312312
return "k"
313313

314-
def _getdefaults(self, ignore, kw):
314+
def _getdefaults(self, kw, ignore=frozenset()):
315315
"""
316316
If some keys in the property cycle (excluding those in the set
317317
*ignore*) are absent or set to None in the dict *kw*, return a copy
@@ -337,8 +337,7 @@ def _setdefaults(self, defaults, kw):
337337

338338
def _makeline(self, axes, x, y, kw, kwargs):
339339
kw = {**kw, **kwargs} # Don't modify the original kw.
340-
default_dict = self._getdefaults(set(), kw)
341-
self._setdefaults(default_dict, kw)
340+
self._setdefaults(self._getdefaults(kw), kw)
342341
seg = mlines.Line2D(x, y, **kw)
343342
return seg, kw
344343

@@ -358,18 +357,16 @@ def _makefill(self, axes, x, y, kw, kwargs):
358357
# *user* explicitly specifies a marker which should be an error.
359358
# We also want to prevent advancing the cycler if there are no
360359
# defaults needed after ignoring the given properties.
361-
ignores = {'marker', 'markersize', 'markeredgecolor',
362-
'markerfacecolor', 'markeredgewidth'}
363-
# Also ignore anything provided by *kwargs*.
364-
for k, v in kwargs.items():
365-
if v is not None:
366-
ignores.add(k)
360+
ignores = ({'marker', 'markersize', 'markeredgecolor',
361+
'markerfacecolor', 'markeredgewidth'}
362+
# Also ignore anything provided by *kwargs*.
363+
| {k for k, v in kwargs.items() if v is not None})
367364

368365
# Only using the first dictionary to use as basis
369366
# for getting defaults for back-compat reasons.
370367
# Doing it with both seems to mess things up in
371368
# various places (probably due to logic bugs elsewhere).
372-
default_dict = self._getdefaults(ignores, kw)
369+
default_dict = self._getdefaults(kw, ignores)
373370
self._setdefaults(default_dict, kw)
374371

375372
# Looks like we don't want "color" to be interpreted to

0 commit comments

Comments
 (0)