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

Method draw

lib/matplotlib/collections.py:361–509  ·  view source on GitHub ↗
(self, renderer)

Source from the content-addressed store, hash-verified

359
360 @artist.allow_rasterization
361 def draw(self, renderer):
362 if not self.get_visible():
363 return
364 renderer.open_group(self.__class__.__name__, self.get_gid())
365
366 self.update_scalarmappable()
367
368 transform, offset_trf, offsets, paths = self._prepare_points()
369
370 gc = renderer.new_gc()
371 self._set_gc_clip(gc)
372 gc.set_snap(self.get_snap())
373
374 if self._hatch:
375 gc.set_hatch(self._hatch)
376 gc.set_hatch_linewidth(self._hatch_linewidth)
377
378 if self.get_sketch_params() is not None:
379 gc.set_sketch_params(*self.get_sketch_params())
380
381 if self.get_path_effects():
382 from matplotlib.patheffects import PathEffectRenderer
383 renderer = PathEffectRenderer(self.get_path_effects(), renderer)
384
385 # If the collection is made up of a single shape/color/stroke,
386 # it can be rendered once and blitted multiple times, using
387 # `draw_markers` rather than `draw_path_collection`. This is
388 # *much* faster for Agg, and results in smaller file sizes in
389 # PDF/SVG/PS.
390
391 trans = self.get_transforms()
392 facecolors = self.get_facecolor()
393 edgecolors = self.get_edgecolor()
394 do_single_path_optimization = False
395 if (len(paths) == 1 and len(trans) <= 1 and
396 len(facecolors) == 1 and len(edgecolors) == 1 and
397 len(self._linewidths) == 1 and
398 all(ls[1] is None for ls in self._linestyles) and
399 len(self._antialiaseds) == 1 and len(self._urls) == 1 and
400 self.get_hatch() is None):
401 if len(trans):
402 combined_transform = transforms.Affine2D(trans[0]) + transform
403 else:
404 combined_transform = transform
405 extents = paths[0].get_extents(combined_transform)
406 if (extents.width < self.get_figure(root=True).bbox.width
407 and extents.height < self.get_figure(root=True).bbox.height):
408 do_single_path_optimization = True
409
410 if self._joinstyle:
411 gc.set_joinstyle(self._joinstyle)
412
413 if self._capstyle:
414 gc.set_capstyle(self._capstyle)
415
416 if do_single_path_optimization:
417 gc.set_foreground(tuple(edgecolors[0]), isRGBA=True)
418 gc.set_linewidth(self._linewidths[0])

Callers

nothing calls this directly

Calls 15

open_groupMethod · 0.95
update_scalarmappableMethod · 0.95
_prepare_pointsMethod · 0.95
get_transformsMethod · 0.95
get_facecolorMethod · 0.95
get_edgecolorMethod · 0.95
get_hatchMethod · 0.95
draw_markersMethod · 0.95
draw_path_collectionMethod · 0.95
get_hatchcolorMethod · 0.95
draw_pathMethod · 0.95
close_groupMethod · 0.95

Tested by

no test coverage detected