Implements a Renderer which contains another renderer. This proxy then intercepts draw calls, calling the appropriate :class:`AbstractPathEffect` draw method. .. note:: Not all methods have been overridden on this RendererBase subclass. It may be necessary to add f
| 69 | |
| 70 | |
| 71 | class PathEffectRenderer(RendererBase): |
| 72 | """ |
| 73 | Implements a Renderer which contains another renderer. |
| 74 | |
| 75 | This proxy then intercepts draw calls, calling the appropriate |
| 76 | :class:`AbstractPathEffect` draw method. |
| 77 | |
| 78 | .. note:: |
| 79 | Not all methods have been overridden on this RendererBase subclass. |
| 80 | It may be necessary to add further methods to extend the PathEffects |
| 81 | capabilities further. |
| 82 | """ |
| 83 | |
| 84 | def __init__(self, path_effects, renderer): |
| 85 | """ |
| 86 | Parameters |
| 87 | ---------- |
| 88 | path_effects : iterable of :class:`AbstractPathEffect` |
| 89 | The path effects which this renderer represents. |
| 90 | renderer : `~matplotlib.backend_bases.RendererBase` subclass |
| 91 | |
| 92 | """ |
| 93 | self._path_effects = path_effects |
| 94 | self._renderer = renderer |
| 95 | |
| 96 | def copy_with_path_effect(self, path_effects): |
| 97 | return self.__class__(path_effects, self._renderer) |
| 98 | |
| 99 | def __getattribute__(self, name): |
| 100 | if name in ['flipy', 'get_canvas_width_height', 'new_gc', |
| 101 | 'points_to_pixels', '_text2path', 'height', 'width']: |
| 102 | return getattr(self._renderer, name) |
| 103 | else: |
| 104 | return object.__getattribute__(self, name) |
| 105 | |
| 106 | def draw_path(self, gc, tpath, affine, rgbFace=None): |
| 107 | for path_effect in self._path_effects: |
| 108 | path_effect.draw_path(self._renderer, gc, tpath, affine, |
| 109 | rgbFace) |
| 110 | |
| 111 | def draw_markers( |
| 112 | self, gc, marker_path, marker_trans, path, *args, **kwargs): |
| 113 | # We do a little shimmy so that all markers are drawn for each path |
| 114 | # effect in turn. Essentially, we induce recursion (depth 1) which is |
| 115 | # terminated once we have just a single path effect to work with. |
| 116 | if len(self._path_effects) == 1: |
| 117 | # Call the base path effect function - this uses the unoptimised |
| 118 | # approach of calling "draw_path" multiple times. |
| 119 | return super().draw_markers(gc, marker_path, marker_trans, path, |
| 120 | *args, **kwargs) |
| 121 | |
| 122 | for path_effect in self._path_effects: |
| 123 | renderer = self.copy_with_path_effect([path_effect]) |
| 124 | # Recursively call this method, only next time we will only have |
| 125 | # one path effect. |
| 126 | renderer.draw_markers(gc, marker_path, marker_trans, path, |
| 127 | *args, **kwargs) |
| 128 |
no outgoing calls
searching dependent graphs…