@@ -124,6 +124,11 @@ def _process_plot_format(fmt):
124
124
return linestyle , marker , color
125
125
126
126
127
+ def _no_none (d ):
128
+ """Return the dict *d*, minus entries with a value of None."""
129
+ return {k : v for k , v in d .items () if v is not None }
130
+
131
+
127
132
class _process_plot_var_args (object ):
128
133
"""
129
134
Process variable length arguments to the plot command, so that
@@ -235,27 +240,14 @@ def _xy_from_xy(self, x, y):
235
240
y = y [:, np .newaxis ]
236
241
return x , y
237
242
238
- def _getdefaults (self , ignore , * kwargs ):
243
+ def _getdefaults (self , ignore , kw ):
239
244
"""
240
- Only advance the cycler if the cycler has information that
241
- is not specified in any of the supplied tuple of dicts.
242
- Ignore any keys specified in the `ignore` set.
243
-
244
- Returns a copy of defaults dictionary if there are any
245
- keys that are not found in any of the supplied dictionaries.
246
- If the supplied dictionaries have non-None values for
247
- everything the property cycler has, then just return
248
- an empty dictionary. Ignored keys are excluded from the
249
- returned dictionary.
250
-
245
+ If some keys in the property cycle (excluding those in the set
246
+ *ignore*) are absent or set to None in the dict *kw*, return a copy
247
+ of the next entry in the property cycle, excluding keys in *ignore*.
248
+ Otherwise, don't advance the property cycle, and return an empty dict.
251
249
"""
252
- prop_keys = self ._prop_keys
253
- if ignore is None :
254
- ignore = set ()
255
- prop_keys = prop_keys - ignore
256
-
257
- if any (all (kw .get (k , None ) is None for kw in kwargs )
258
- for k in prop_keys ):
250
+ if self ._prop_keys - ignore - {* _no_none (kw )}:
259
251
# Need to copy this dictionary or else the next time around
260
252
# in the cycle, the dictionary could be missing entries.
261
253
default_dict = next (self .prop_cycler ).copy ()
@@ -265,22 +257,10 @@ def _getdefaults(self, ignore, *kwargs):
265
257
default_dict = {}
266
258
return default_dict
267
259
268
- def _setdefaults (self , defaults , * kwargs ):
269
- """
270
- Given a defaults dictionary, and any other dictionaries,
271
- update those other dictionaries with information in defaults if
272
- none of the other dictionaries contains that information.
273
-
274
- """
275
- for k in defaults :
276
- if all (kw .get (k , None ) is None for kw in kwargs ):
277
- for kw in kwargs :
278
- kw [k ] = defaults [k ]
279
-
280
260
def _makeline (self , x , y , kw , kwargs ):
281
261
kw = {** kw , ** kwargs } # Don't modify the original kw.
282
- default_dict = self ._getdefaults (None , kw )
283
- self . _setdefaults ( default_dict , kw )
262
+ default_dict = self ._getdefaults (set () , kw )
263
+ kw = { ** default_dict , ** _no_none ( kw )}
284
264
seg = mlines .Line2D (x , y , ** kw )
285
265
return seg
286
266
@@ -308,7 +288,7 @@ def _makefill(self, x, y, kw, kwargs):
308
288
# Doing it with both seems to mess things up in
309
289
# various places (probably due to logic bugs elsewhere).
310
290
default_dict = self ._getdefaults (ignores , kw )
311
- self . _setdefaults ( default_dict , kw )
291
+ kw = { ** default_dict , ** _no_none ( kw )}
312
292
313
293
# Looks like we don't want "color" to be interpreted to
314
294
# mean both facecolor and edgecolor for some reason.
@@ -323,7 +303,7 @@ def _makefill(self, x, y, kw, kwargs):
323
303
324
304
# To get other properties set from the cycler
325
305
# modify the kwargs dictionary.
326
- self . _setdefaults ( default_dict , kwargs )
306
+ kwargs = { ** default_dict , ** _no_none ( kwargs )}
327
307
328
308
seg = mpatches .Polygon (np .column_stack ((x , y )),
329
309
facecolor = facecolor ,
@@ -391,8 +371,6 @@ def _grab_next_args(self, *args, **kwargs):
391
371
392
372
393
373
class _AxesBase (martist .Artist ):
394
- """
395
- """
396
374
name = "rectilinear"
397
375
398
376
_shared_x_axes = cbook .Grouper ()
0 commit comments