MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _make_polygon

Method _make_polygon

lib/matplotlib/axes/_base.py:361–409  ·  view source on GitHub ↗
(self, axes, x, y, kw, kwargs)

Source from the content-addressed store, hash-verified

359 return (x, y), kw
360
361 def _make_polygon(self, axes, x, y, kw, kwargs):
362 # Polygon doesn't directly support unitized inputs.
363 x = axes.convert_xunits(x)
364 y = axes.convert_yunits(y)
365
366 kw = kw.copy() # Don't modify the original kw.
367 kwargs = kwargs.copy()
368
369 # Ignore 'marker'-related properties as they aren't Polygon
370 # properties, but they are Line2D properties, and so they are
371 # likely to appear in the default cycler construction.
372 # This is done here to the defaults dictionary as opposed to the
373 # other two dictionaries because we do want to capture when a
374 # *user* explicitly specifies a marker which should be an error.
375 # We also want to prevent advancing the cycler if there are no
376 # defaults needed after ignoring the given properties.
377 ignores = ({'marker', 'markersize', 'markeredgecolor',
378 'markerfacecolor', 'markeredgewidth'}
379 # Also ignore anything provided by *kwargs*.
380 | {k for k, v in kwargs.items() if v is not None})
381
382 # Only using the first dictionary to use as basis
383 # for getting defaults for back-compat reasons.
384 # Doing it with both seems to mess things up in
385 # various places (probably due to logic bugs elsewhere).
386 default_dict = self._prop_cycle.getdefaults(kw, ignores)
387 self._setdefaults(default_dict, kw)
388
389 # Looks like we don't want "color" to be interpreted to
390 # mean both facecolor and edgecolor for some reason.
391 # So the "kw" dictionary is thrown out, and only its
392 # 'color' value is kept and translated as a 'facecolor'.
393 # This design should probably be revisited as it increases
394 # complexity.
395 facecolor = kw.get('color', None)
396
397 # Throw out 'color' as it is now handled as a facecolor
398 default_dict.pop('color', None)
399
400 # To get other properties set from the cycler
401 # modify the kwargs dictionary.
402 self._setdefaults(default_dict, kwargs)
403
404 seg = mpatches.Polygon(np.column_stack((x, y)),
405 facecolor=facecolor,
406 fill=kwargs.get('fill', True),
407 closed=kw['closed'])
408 seg.set(**kwargs)
409 return seg, kwargs
410
411 def _plot_args(self, axes, tup, kwargs, *,
412 return_kwargs=False, ambiguous_fmt_datakey=False):

Callers

nothing calls this directly

Calls 8

_setdefaultsMethod · 0.95
convert_xunitsMethod · 0.80
convert_yunitsMethod · 0.80
getdefaultsMethod · 0.80
copyMethod · 0.45
getMethod · 0.45
popMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected