matplotlib.backends.backend_agg
¶An agg http://antigrain.com/ backend
Features that are implemented
- capstyles and join styles
- dashes
- linewidth
- lines, rectangles, ellipses
- clipping to a rectangle
- output to RGBA and PNG, optionally JPEG and TIFF
- alpha blending
- DPI scaling properly - everything scales properly (dashes, linewidths, etc)
- draw polygon
- freetype2 w/ ft2font
TODO:
- integrate screen dpi w/ ppi and text
matplotlib.backends.backend_agg.
FigureCanvas
¶matplotlib.backends.backend_agg.
FigureCanvasAgg
(figure)[source]¶Bases: matplotlib.backend_bases.FigureCanvasBase
The canvas the figure renders into. Calls the draw and print fig methods, creates the renderers, etc...
Attributes: |
|
---|
buffer_rgba
()[source]¶Get the image as an RGBA byte string
draw
must be called at least once before this function will work and
to update the renderer for any subsequent changes to the Figure.
Returns: |
|
---|
print_jpeg
(filename_or_obj, *args, **kwargs)¶Other Parameters: |
|
---|
print_jpg
(filename_or_obj, *args, **kwargs)[source]¶Other Parameters: |
|
---|
print_rgba
(filename_or_obj, *args, **kwargs)¶print_tiff
(filename_or_obj, *args, **kwargs)¶matplotlib.backends.backend_agg.
RendererAgg
(width, height, dpi)[source]¶Bases: matplotlib.backend_bases.RendererBase
The renderer handles all the drawing primitives using a graphics context instance that controls the colors/styles
debug
¶Deprecated since version 2.2: The debug function was deprecated in version 2.2.
draw_markers
(*kl, **kw)[source]¶Draws a marker at each of the vertices in path. This includes all vertices, including control points on curves. To avoid that behavior, those vertices should be removed before calling this function.
This provides a fallback implementation of draw_markers that
makes multiple calls to draw_path()
. Some backends may
want to override this method in order to draw the marker only
once and reuse it multiple times.
Parameters: |
|
---|
draw_path_collection
(*kl, **kw)[source]¶Draws a collection of paths selecting drawing properties from the lists facecolors, edgecolors, linewidths, linestyles and antialiaseds. offsets is a list of offsets to apply to each of the paths. The offsets in offsets are first transformed by offsetTrans before being applied. offset_position may be either "screen" or "data" depending on the space that the offsets are in.
This provides a fallback implementation of
draw_path_collection()
that makes multiple calls to
draw_path()
. 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
_iter_collection_raw_paths()
and
_iter_collection()
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 draw_path_collection()
can be made globally.
get_text_width_height_descent
(s, prop, ismath)[source]¶Get the width, height, and descent (offset from the bottom
to the baseline), in display coords, of the string s with
FontProperties
prop
lock
= <unlocked _thread.RLock object owner=0 count=0>¶option_image_nocomposite
()[source]¶override this method for renderers that do not necessarily always want to rescale and composite raster images. (like SVG, PDF, or PS)
points_to_pixels
(points)[source]¶convert point measures to pixes using dpi and the pixels per inch of the display
restore_region
(region, bbox=None, xy=None)[source]¶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 tuple of two floasts) 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))
stop_filter
(post_processing)[source]¶Save the plot in the current canvas as a image and apply 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.