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

Class PatchCollection

lib/matplotlib/collections.py:2206–2263  ·  view source on GitHub ↗

A generic collection of patches. PatchCollection draws faster than a large number of equivalent individual Patches. It also makes it easier to assign a colormap to a heterogeneous collection of patches.

Source from the content-addressed store, hash-verified

2204
2205
2206class PatchCollection(Collection):
2207 """
2208 A generic collection of patches.
2209
2210 PatchCollection draws faster than a large number of equivalent individual
2211 Patches. It also makes it easier to assign a colormap to a heterogeneous
2212 collection of patches.
2213 """
2214
2215 def __init__(self, patches, *, match_original=False, **kwargs):
2216 """
2217 Parameters
2218 ----------
2219 patches : list of `.Patch`
2220 A sequence of Patch objects. This list may include
2221 a heterogeneous assortment of different patch types.
2222
2223 match_original : bool, default: False
2224 If True, use the colors and linewidths of the original
2225 patches. If False, new colors may be assigned by
2226 providing the standard collection arguments, facecolor,
2227 edgecolor, linewidths, norm or cmap.
2228
2229 **kwargs
2230 All other parameters are forwarded to `.Collection`.
2231
2232 If any of *edgecolors*, *facecolors*, *linewidths*, *antialiaseds*
2233 are None, they default to their `.rcParams` patch setting, in
2234 sequence form.
2235
2236 Notes
2237 -----
2238 The use of `~matplotlib.cm.ScalarMappable` functionality is optional.
2239 If the `~matplotlib.cm.ScalarMappable` matrix ``_A`` has been set (via
2240 a call to `~.ScalarMappable.set_array`), at draw time a call to scalar
2241 mappable will be made to set the face colors.
2242 """
2243
2244 if match_original:
2245 def determine_facecolor(patch):
2246 if patch.get_fill():
2247 return patch.get_facecolor()
2248 return [0, 0, 0, 0]
2249
2250 kwargs['facecolors'] = [determine_facecolor(p) for p in patches]
2251 kwargs['edgecolors'] = [p.get_edgecolor() for p in patches]
2252 kwargs['linewidths'] = [p.get_linewidth() for p in patches]
2253 kwargs['linestyles'] = [p.get_linestyle() for p in patches]
2254 kwargs['antialiaseds'] = [p.get_antialiased() for p in patches]
2255
2256 super().__init__(**kwargs)
2257
2258 self.set_paths(patches)
2259
2260 def set_paths(self, patches):
2261 paths = [p.get_transform().transform_path(p.get_path())
2262 for p in patches]
2263 self._paths = paths

Callers 2

make_error_boxesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…