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.
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.
Draw a Path instance using the given affine transform.
draw_tex(gc, x, y, s, prop, angle, *, mtext=None)
Draw a TeX instance.
Parameters:
gc :
draw_text(gc, x, y, s, prop, angle, ismath=False, mtext=None)
Draw a text instance.
Parameters:
gc :
get_canvas_width_height()
Return the canvas width and height in display coords.
get_text_width_height_descent(s, prop, ismath)
Get the width, height, and descent (offset from the bottom to the baseline), in
display coords, of the string s with FontPropertiesprop.
Whitespace at the start and the end of s is included in the reported width.
option_image_nocomposite()
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 notrcParams["image.composite_image"].
option_scale_image()
Return whether arbitrary affine transformations in
draw_image are supported (True for most vector backends).
points_to_pixels(points)
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:
pointstopixels=points*pixels_per_inch/72*dpi/72
Parameters:
restore_region(region, bbox=None, xy=None)
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,
start_filter()
Start filtering. It simply creates a new canvas (the old one is saved).
stop_filter(post_processing)
Save the current canvas as an image and apply post processing.
The post_processing function:
defpost_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 imagereturnnew_image,offset_x
RendererBase.draw_text also supports passing "TeX" to the ismath
parameter to use TeX rendering, but this is not required for actual
rendering backends, and indeed many builtin backends do not support
this. Rather, TeX rendering is provided by draw_tex.
points
: float or array-like
Returns:
Points converted to pixels
x2
,
y2
=
region
.
get_extents
()
>>>
renderer
.
restore_region
(
region
,
bbox
=
(
x1
+
dx
,
y1
,
x2
,
y2
),
...
xy
=
(
x1
-
dx
,
y1
))
,
offset_y
The saved renderer is restored and the returned image from
post_processing is plotted (using draw_image) on it.