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

Class MixedModeRenderer

lib/matplotlib/backends/backend_mixed.py:8–122  ·  view source on GitHub ↗

A helper class to implement a renderer that switches between vector and raster drawing. An example may be a PDF writer, where most things are drawn with PDF vector commands, but some very complex objects, such as quad meshes, are rasterised and then output as images.

Source from the content-addressed store, hash-verified

6
7
8class MixedModeRenderer:
9 """
10 A helper class to implement a renderer that switches between
11 vector and raster drawing. An example may be a PDF writer, where
12 most things are drawn with PDF vector commands, but some very
13 complex objects, such as quad meshes, are rasterised and then
14 output as images.
15 """
16 def __init__(self, figure, width, height, dpi, vector_renderer,
17 raster_renderer_class=None,
18 bbox_inches_restore=None):
19 """
20 Parameters
21 ----------
22 figure : `~matplotlib.figure.Figure`
23 The figure instance.
24 width : float
25 The width of the canvas in logical units
26 height : float
27 The height of the canvas in logical units
28 dpi : float
29 The dpi of the canvas
30 vector_renderer : `~matplotlib.backend_bases.RendererBase`
31 An instance of a subclass of
32 `~matplotlib.backend_bases.RendererBase` that will be used for the
33 vector drawing.
34 raster_renderer_class : `~matplotlib.backend_bases.RendererBase`
35 The renderer class to use for the raster drawing. If not provided,
36 this will use the Agg backend (which is currently the only viable
37 option anyway.)
38
39 """
40 if raster_renderer_class is None:
41 raster_renderer_class = RendererAgg
42
43 self._raster_renderer_class = raster_renderer_class
44 self._width = width
45 self._height = height
46 self.dpi = dpi
47
48 self._vector_renderer = vector_renderer
49
50 self._raster_renderer = None
51
52 # A reference to the figure is needed as we need to change
53 # the figure dpi before and after the rasterization. Although
54 # this looks ugly, I couldn't find a better solution. -JJL
55 self.figure = figure
56 self._figdpi = figure.dpi
57
58 self._bbox_inches_restore = bbox_inches_restore
59
60 self._renderer = vector_renderer
61
62 def __getattr__(self, attr):
63 # Proxy everything that hasn't been overridden to the base
64 # renderer. Things that *are* overridden can call methods
65 # on self._renderer directly, but must not cache/store

Callers 5

_print_figureMethod · 0.90
_print_figure_texMethod · 0.90
_print_pgf_to_fhMethod · 0.90
print_pdfMethod · 0.90
print_svgMethod · 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…