An Anti-Grain Geometry (AGG) backend.
Features that are implemented:
Still TODO:
alias of FigureCanvasAgg
Bases: FigureCanvasBase
Get the image as a memoryview to the renderer's buffer.
draw must be called at least once before this function will work and to update the renderer for any subsequent changes to the Figure.
Render the Figure.
This method must walk the artist tree, even if no output is produced, because it triggers deferred work that users may want to access before saving output to disk. For example computing limits, auto-limits, and tick values.
Write the figure to a JPEG file.
The file to write to.
Additional keyword arguments that are passed to PIL.Image.Image.save when saving the figure.
Write the figure to a JPEG file.
The file to write to.
Additional keyword arguments that are passed to PIL.Image.Image.save when saving the figure.
Write the figure to a PNG file.
The file to write to.
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.
The PNG specification defines some common keywords that may be used as appropriate:
Other keywords may be invented for other purposes.
If 'Software' is not given, an autogenerated value for Matplotlib will be used. This can be removed by setting it to None.
For more details see the PNG specification.
Keyword arguments passed to PIL.Image.Image.save.
If the 'pnginfo' key is present, it completely overrides metadata, including the default 'Software' key.
Write the figure to a TIFF file.
The file to write to.
Additional keyword arguments that are passed to PIL.Image.Image.save when saving the figure.
Write the figure to a TIFF file.
The file to write to.
Additional keyword arguments that are passed to PIL.Image.Image.save when saving the figure.
Write the figure to a WebP file.
The file to write to.
Additional keyword arguments that are passed to PIL.Image.Image.save when saving the figure.
Bases: RendererBase
The renderer handles all the drawing primitives using a graphics context instance that controls the colors/styles
Draw mathtext using matplotlib.mathtext.
Draw a Path instance using the given affine transform.
Draw a TeX instance.
GraphicsContextBase
The graphics context.
The x location of the text in display coords.
The y location of the text baseline in display coords.
The TeX text string.
FontProperties
The font properties.
The rotation angle in degrees anti-clockwise.
Text
The original text object to be rendered.
Draw a text instance.
GraphicsContextBase
The graphics context.
The x location of the text in display coords.
The y location of the text baseline in display coords.
The text string.
FontProperties
The font properties.
The rotation angle in degrees anti-clockwise.
If True, use mathtext parser. If "TeX", use tex for rendering.
Text
The original text object to be rendered.
Return the canvas width and height in display coords.
Get the width, height, and descent (offset from the bottom to the baseline), in display coords, of the string s with FontProperties prop.
Whitespace at the start and the end of s is included in the reported width.
Return whether image composition by Matplotlib should be skipped.
Raster backends should usually return False (letting the C-level rasterizer take care of image composition); vector backends should usually return not rcParams["image.composite_image"].
Return whether arbitrary affine transformations in draw_image are supported (True for most vector backends).
Convert points to display units.
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:
points to pixels = points * pixels_per_inch/72 * dpi/72
Restore the saved region. If bbox (instance of BboxBase, or its extents) is given, only the region specified by the bbox will be restored. xy (a pair of floats) optionally specifies the new position (the LLC of the original region, not the LLC of the bbox) where the region will be restored.
>>> region = renderer.copy_from_bbox() >>> x1, y1, x2, y2 = region.get_extents() >>> renderer.restore_region(region, bbox=(x1+dx, y1, x2, y2), ... xy=(x1-dx, y1))
Start filtering. It simply creates a new canvas (the old one is saved).
Save the current canvas as an image and apply post processing.
The post_processing function:
def post_processing(image, dpi): # ny, nx, depth = image.shape # image (numpy array) has RGBA channels and has a depth of 4. ... # create a new_image (numpy array of 4 channels, size can be # different). The resulting image may have offsets from # lower-left corner of the original image return new_image, offset_x, offset_y
The saved renderer is restored and the returned image from post_processing is plotted (using draw_image) on it.
[Deprecated]
Deprecated since version 3.8: Use buffer_rgba instead.
© 2012–2023 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/stable/api/backend_agg_api.html