<divid="unreleased-message"> You are reading an old version of the documentation (v3.3.1). For the latest version see <ahref="https://matplotlib.org/stable/api/backend_agg_api.html">https://matplotlib.org/stable/api/backend_agg_api.html</a></div>
<codeclass="descclassname">matplotlib.backends.backend_agg.</code><codeclass="descname">FigureCanvas</code><aclass="headerlink" href="#matplotlib.backends.backend_agg.FigureCanvas" title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="descclassname">matplotlib.backends.backend_agg.</code><codeclass="descname">FigureCanvasAgg</code><spanclass="sig-paren">(</span><em><spanclass="n">figure</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#FigureCanvasAgg"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.FigureCanvasAgg" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">buffer_rgba</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#FigureCanvasAgg.buffer_rgba"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.FigureCanvasAgg.buffer_rgba" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the image as a <aclass="reference external" href="https://docs.python.org/3/library/stdtypes.html#memoryview" title="(in Python v3.8)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">memoryview</span></code></a> to the renderer's buffer.</p>
<p><aclass="reference internal" href="#matplotlib.backends.backend_agg.FigureCanvasAgg.draw" title="matplotlib.backends.backend_agg.FigureCanvasAgg.draw"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">draw</span></code></a> must be called at least once before this function will work and
to update the renderer for any subsequent changes to the Figure.</p>
<codeclass="descname">copy_from_bbox</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">bbox</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#FigureCanvasAgg.copy_from_bbox"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.FigureCanvasAgg.copy_from_bbox" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">draw</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#FigureCanvasAgg.draw"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.FigureCanvasAgg.draw" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">get_renderer</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">cleared</span><spanclass="o">=</span><spanclass="default_value">False</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#FigureCanvasAgg.get_renderer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.FigureCanvasAgg.get_renderer" title="Permalink to this definition">¶</a></dt>
<dt><strong>filename_or_obj</strong><spanclass="classifier">str or path-like or file-like</span></dt><dd><p>The file to write to.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Other Parameters:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>quality</strong><spanclass="classifier">int, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=savefig.jpeg_quality#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["savefig.jpeg_quality"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">95</span></code>)</span></dt><dd><p>The image quality, on a scale from 1 (worst) to 95 (best).
Values above 95 should be avoided; 100 disables portions of
the JPEG compression algorithm, and results in large files
with hardly any gain in image quality. This parameter is
deprecated.</p>
</dd>
<dt><strong>optimize</strong><spanclass="classifier">bool, default: False</span></dt><dd><p>Whether the encoder should make an extra pass over the image
in order to select optimal encoder settings. This parameter is
deprecated.</p>
</dd>
<dt><strong>progressive</strong><spanclass="classifier">bool, default: False</span></dt><dd><p>Whether the image should be stored as a progressive JPEG file.
This parameter is deprecated.</p>
</dd>
<dt><strong>pil_kwargs</strong><spanclass="classifier">dict, optional</span></dt><dd><p>Additional keyword arguments that are passed to
<aclass="reference external" href="https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.save" title="(in Pillow (PIL Fork) v7.2.0)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">PIL.Image.Image.save</span></code></a> when saving the figure. These take
precedence over <em>quality</em>, <em>optimize</em> and <em>progressive</em>.</p>
<dt><strong>filename_or_obj</strong><spanclass="classifier">str or path-like or file-like</span></dt><dd><p>The file to write to.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Other Parameters:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>quality</strong><spanclass="classifier">int, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=savefig.jpeg_quality#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["savefig.jpeg_quality"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">95</span></code>)</span></dt><dd><p>The image quality, on a scale from 1 (worst) to 95 (best).
Values above 95 should be avoided; 100 disables portions of
the JPEG compression algorithm, and results in large files
with hardly any gain in image quality. This parameter is
deprecated.</p>
</dd>
<dt><strong>optimize</strong><spanclass="classifier">bool, default: False</span></dt><dd><p>Whether the encoder should make an extra pass over the image
in order to select optimal encoder settings. This parameter is
deprecated.</p>
</dd>
<dt><strong>progressive</strong><spanclass="classifier">bool, default: False</span></dt><dd><p>Whether the image should be stored as a progressive JPEG file.
This parameter is deprecated.</p>
</dd>
<dt><strong>pil_kwargs</strong><spanclass="classifier">dict, optional</span></dt><dd><p>Additional keyword arguments that are passed to
<aclass="reference external" href="https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.save" title="(in Pillow (PIL Fork) v7.2.0)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">PIL.Image.Image.save</span></code></a> when saving the figure. These take
precedence over <em>quality</em>, <em>optimize</em> and <em>progressive</em>.</p>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>filename_or_obj</strong><spanclass="classifier">str or path-like or file-like</span></dt><dd><p>The file to write to.</p>
</dd>
<dt><strong>metadata</strong><spanclass="classifier">dict, optional</span></dt><dd><p>Metadata in the PNG file as key-value pairs of bytes or latin-1
encodable strings.
According to the PNG specification, keys must be shorter than 79
chars.</p>
<p>The <aclass="reference external" href="https://www.w3.org/TR/2003/REC-PNG-20031110/#11keywords">PNG specification</a> defines some common keywords that may be
used as appropriate:</p>
<ulclass="simple">
<li>Title: Short (one line) title or caption for image.</li>
<li>Author: Name of image's creator.</li>
<li>Description: Description of image (possibly long).</li>
<li>Copyright: Copyright notice.</li>
<li>Creation Time: Time of original image creation
(usually RFC 1123 format).</li>
<li>Software: Software used to create the image.</li>
<li>Disclaimer: Legal disclaimer.</li>
<li>Warning: Warning of nature of content.</li>
<li>Source: Device used to create the image.</li>
<li>Comment: Miscellaneous comment;
conversion from other image format.</li>
</ul>
<p>Other keywords may be invented for other purposes.</p>
<p>If 'Software' is not given, an autogenerated value for Matplotlib
will be used. This can be removed by setting it to <em>None</em>.</p>
<p>For more details see the <aclass="reference external" href="https://www.w3.org/TR/2003/REC-PNG-20031110/#11keywords">PNG specification</a>.</p>
<codeclass="descname">print_raw</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">filename_or_obj</span></em>, <em><spanclass="o">*</span><spanclass="n">args</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#FigureCanvasAgg.print_raw"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.FigureCanvasAgg.print_raw" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">print_rgba</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">filename_or_obj</span></em>, <em><spanclass="o">*</span><spanclass="n">args</span></em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.backends.backend_agg.FigureCanvasAgg.print_rgba" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">print_to_buffer</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#FigureCanvasAgg.print_to_buffer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.FigureCanvasAgg.print_to_buffer" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">tostring_argb</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#FigureCanvasAgg.tostring_argb"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.FigureCanvasAgg.tostring_argb" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the image as ARGB <aclass="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytes" title="(in Python v3.8)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">bytes</span></code></a>.</p>
<p><aclass="reference internal" href="#matplotlib.backends.backend_agg.FigureCanvasAgg.draw" title="matplotlib.backends.backend_agg.FigureCanvasAgg.draw"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">draw</span></code></a> must be called at least once before this function will work and
to update the renderer for any subsequent changes to the Figure.</p>
<codeclass="descname">tostring_rgb</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#FigureCanvasAgg.tostring_rgb"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.FigureCanvasAgg.tostring_rgb" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the image as RGB <aclass="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytes" title="(in Python v3.8)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">bytes</span></code></a>.</p>
<p><aclass="reference internal" href="#matplotlib.backends.backend_agg.FigureCanvasAgg.draw" title="matplotlib.backends.backend_agg.FigureCanvasAgg.draw"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">draw</span></code></a> must be called at least once before this function will work and
to update the renderer for any subsequent changes to the Figure.</p>
<codeclass="descname">buffer_rgba</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#RendererAgg.buffer_rgba"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.RendererAgg.buffer_rgba" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">clear</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#RendererAgg.clear"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.RendererAgg.clear" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">draw_path</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">gc</span></em>, <em><spanclass="n">path</span></em>, <em><spanclass="n">transform</span></em>, <em><spanclass="n">rgbFace</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#RendererAgg.draw_path"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.RendererAgg.draw_path" title="Permalink to this definition">¶</a></dt>
<dd><p>Draw a <aclass="reference internal" href="path_api.html#matplotlib.path.Path" title="matplotlib.path.Path"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Path</span></code></a> instance using the given affine transform.</p>
<dd><p>Draw a collection of paths selecting drawing properties from
the lists <em>facecolors</em>, <em>edgecolors</em>, <em>linewidths</em>,
<em>linestyles</em> and <em>antialiaseds</em>. <em>offsets</em> is a list of
offsets to apply to each of the paths. The offsets in
<em>offsets</em> are first transformed by <em>offsetTrans</em> before being
applied.</p>
<p><em>offset_position</em> may be either "screen" or "data" depending on the
space that the offsets are in; "data" is deprecated.</p>
<p>This provides a fallback implementation of
<aclass="reference internal" href="#matplotlib.backends.backend_agg.RendererAgg.draw_path_collection" title="matplotlib.backends.backend_agg.RendererAgg.draw_path_collection"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">draw_path_collection()</span></code></a> that makes multiple calls to
<aclass="reference internal" href="#matplotlib.backends.backend_agg.RendererAgg.draw_path" title="matplotlib.backends.backend_agg.RendererAgg.draw_path"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">draw_path()</span></code></a>. Some backends may want to override this in
order to render each set of path data only once, and then
reference that path multiple times with the different offsets,
colors, styles etc. The generator methods
<codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">_iter_collection_raw_paths()</span></code> and
<codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">_iter_collection()</span></code> are provided to help with (and
standardize) the implementation across backends. It is highly
recommended to use those generators, so that changes to the
behavior of <aclass="reference internal" href="#matplotlib.backends.backend_agg.RendererAgg.draw_path_collection" title="matplotlib.backends.backend_agg.RendererAgg.draw_path_collection"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">draw_path_collection()</span></code></a> can be made globally.</p>
<dt><strong>angle</strong><spanclass="classifier">float</span></dt><dd><p>The rotation angle in degrees anti-clockwise.</p>
</dd>
<dt><strong>mtext</strong><spanclass="classifier"><aclass="reference internal" href="text_api.html#matplotlib.text.Text" title="matplotlib.text.Text"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">matplotlib.text.Text</span></code></a></span></dt><dd><p>The original text object to be rendered.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<pclass="rubric">Notes</p>
<p><strong>Note for backend implementers:</strong></p>
<p>When you are trying to determine if you have gotten your bounding box
right (which is what enables the text layout/alignment to work
properly), it helps to change the line in text.py:</p>
<codeclass="descname">get_canvas_width_height</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#RendererAgg.get_canvas_width_height"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.RendererAgg.get_canvas_width_height" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the canvas width and height in display coords.</p>
<codeclass="descname">option_image_nocomposite</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#RendererAgg.option_image_nocomposite"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.RendererAgg.option_image_nocomposite" title="Permalink to this definition">¶</a></dt>
<dd><p>Return whether image composition by Matplotlib should be skipped.</p>
<p>Raster backends should usually return False (letting the C-level
rasterizer take care of image composition); vector backends should
usually return <codeclass="docutils literal notranslate"><spanclass="pre">not</span><spanclass="pre">rcParams["image.composite_image"]</span></code>.</p>
<codeclass="descname">option_scale_image</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#RendererAgg.option_scale_image"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.RendererAgg.option_scale_image" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">points_to_pixels</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">points</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#RendererAgg.points_to_pixels"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.RendererAgg.points_to_pixels" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert points to display units.</p>
<p>You need to override this function (unless your backend
doesn't have a dpi, e.g., postscript or svg). Some imaging
systems assume some value for pixels per inch:</p>
<codeclass="descname">start_filter</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#RendererAgg.start_filter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.RendererAgg.start_filter" title="Permalink to this definition">¶</a></dt>
<dd><p>Start filtering. It simply create a new canvas (the old one is saved).</p>
<codeclass="descname">stop_filter</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">post_processing</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#RendererAgg.stop_filter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.RendererAgg.stop_filter" title="Permalink to this definition">¶</a></dt>
<dd><p>Save the plot in the current canvas as a image and apply
<codeclass="descname">tostring_argb</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#RendererAgg.tostring_argb"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.RendererAgg.tostring_argb" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">tostring_rgb</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#RendererAgg.tostring_rgb"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.RendererAgg.tostring_rgb" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">tostring_rgba_minimized</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#RendererAgg.tostring_rgba_minimized"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.RendererAgg.tostring_rgba_minimized" title="Permalink to this definition">¶</a></dt>
<codeclass="descclassname">matplotlib.backends.backend_agg.</code><codeclass="descname">get_hinting_flag</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/backends/backend_agg.html#get_hinting_flag"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.backends.backend_agg.get_hinting_flag" title="Permalink to this definition">¶</a></dt>