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

Method draw

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

Source from the content-addressed store, hash-verified

2539
2540 @artist.allow_rasterization
2541 def draw(self, renderer):
2542 if not self.get_visible():
2543 return
2544 renderer.open_group(self.__class__.__name__, self.get_gid())
2545 transform = self.get_transform()
2546 offset_trf = self.get_offset_transform()
2547 offsets = self.get_offsets()
2548
2549 if self.have_units():
2550 xs = self.convert_xunits(offsets[:, 0])
2551 ys = self.convert_yunits(offsets[:, 1])
2552 offsets = np.column_stack([xs, ys])
2553
2554 self.update_scalarmappable()
2555
2556 if not transform.is_affine:
2557 coordinates = self._coordinates.reshape((-1, 2))
2558 coordinates = transform.transform(coordinates)
2559 coordinates = coordinates.reshape(self._coordinates.shape)
2560 transform = transforms.IdentityTransform()
2561 else:
2562 coordinates = self._coordinates
2563
2564 if not offset_trf.is_affine:
2565 offsets = offset_trf.transform_non_affine(offsets)
2566 offset_trf = offset_trf.get_affine()
2567
2568 gc = renderer.new_gc()
2569 gc.set_snap(self.get_snap())
2570 self._set_gc_clip(gc)
2571 gc.set_linewidth(self.get_linewidth()[0])
2572
2573 if self._shading == 'gouraud':
2574 triangles, colors = self._convert_mesh_to_triangles(coordinates)
2575 renderer.draw_gouraud_triangles(
2576 gc, triangles, colors, transform.frozen())
2577 else:
2578 renderer.draw_quad_mesh(
2579 gc, transform.frozen(),
2580 coordinates.shape[1] - 1, coordinates.shape[0] - 1,
2581 coordinates, offsets, offset_trf,
2582 # Backends expect flattened rgba arrays (n*m, 4) for fc and ec
2583 self.get_facecolor().reshape((-1, 4)),
2584 self._antialiased, self.get_edgecolors().reshape((-1, 4)))
2585 gc.restore()
2586 renderer.close_group(self.__class__.__name__)
2587 self.stale = False
2588
2589 def get_cursor_data(self, event):
2590 contained, info = self.contains(event)

Callers

nothing calls this directly

Calls 15

transformMethod · 0.95
frozenMethod · 0.95
get_offset_transformMethod · 0.80
get_offsetsMethod · 0.80
convert_xunitsMethod · 0.80
convert_yunitsMethod · 0.80
update_scalarmappableMethod · 0.80
_set_gc_clipMethod · 0.80
draw_quad_meshMethod · 0.80
get_visibleMethod · 0.45
open_groupMethod · 0.45

Tested by

no test coverage detected