patheffects

matplotlib.patheffects

Defines classes for path effects. The path effects are supported in Text, Line2D and Patch.

class matplotlib.patheffects.AbstractPathEffect(offset=(0.0, 0.0)) [source]

Bases: object

A base class for path effects.

Subclasses should override the draw_path method to add effect functionality.

Parameters:
offset : pair of floats

The offset to apply to the path, measured in points.

draw_path(renderer, gc, tpath, affine, rgbFace=None) [source]

Derived should override this method. The arguments are the same as matplotlib.backend_bases.RendererBase.draw_path() except the first argument is a renderer.

class matplotlib.patheffects.Normal(offset=(0.0, 0.0)) [source]

Bases: matplotlib.patheffects.AbstractPathEffect

The "identity" PathEffect.

The Normal PathEffect's sole purpose is to draw the original artist with no special path effect.

Parameters:
offset : pair of floats

The offset to apply to the path, measured in points.

class matplotlib.patheffects.PathEffectRenderer(path_effects, renderer) [source]

Bases: matplotlib.backend_bases.RendererBase

Implements a Renderer which contains another renderer.

This proxy then intercepts draw calls, calling the appropriate AbstractPathEffect draw method.

Note

Not all methods have been overridden on this RendererBase subclass. It may be necessary to add further methods to extend the PathEffects capabilities further.

Parameters:
path_effects : iterable of AbstractPathEffect

The path effects which this renderer represents.

renderer : matplotlib.backend_bases.RendererBase instance
copy_with_path_effect(path_effects) [source]
draw_markers(gc, marker_path, marker_trans, path, *args, **kwargs) [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:
gc : GraphicsContextBase

The graphics context

marker_trans : matplotlib.transforms.Transform

An affine transform applied to the marker.

trans : matplotlib.transforms.Transform

An affine transform applied to the path.

draw_path(gc, tpath, affine, rgbFace=None) [source]

Draws a Path instance using the given affine transform.

draw_path_collection(gc, master_transform, paths, *args, **kwargs) [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.

new_gc() [source]

Return an instance of a GraphicsContextBase

points_to_pixels(points) [source]

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.0 * dpi/72.0
Parameters:
points : scalar or array_like

a float or a numpy array of float

Returns:
Points converted to pixels
class matplotlib.patheffects.PathPatchEffect(offset=(0, 0), **kwargs) [source]

Bases: matplotlib.patheffects.AbstractPathEffect

Draws a PathPatch instance whose Path comes from the original PathEffect artist.

Parameters:
offset : pair of floats

The offset to apply to the path, in points.

**kwargs :

All keyword arguments are passed through to the PathPatch constructor. The properties which cannot be overridden are "path", "clip_box" "transform" and "clip_path".

draw_path(renderer, gc, tpath, affine, rgbFace) [source]

Derived should override this method. The arguments are the same as matplotlib.backend_bases.RendererBase.draw_path() except the first argument is a renderer.

class matplotlib.patheffects.SimpleLineShadow(offset=(2, -2), shadow_color='k', alpha=0.3, rho=0.3, **kwargs) [source]

Bases: matplotlib.patheffects.AbstractPathEffect

A simple shadow via a line.

Parameters:
offset : pair of floats

The offset to apply to the path, in points.

shadow_color : color

The shadow color. Default is black. A value of None takes the original artist's color with a scale factor of rho.

alpha : float

The alpha transparency of the created shadow patch. Default is 0.3.

rho : float

A scale factor to apply to the rgbFace color if shadow_rgbFace is None. Default is 0.3.

**kwargs

Extra keywords are stored and passed through to AbstractPathEffect._update_gc().

draw_path(renderer, gc, tpath, affine, rgbFace) [source]

Overrides the standard draw_path to add the shadow offset and necessary color changes for the shadow.

class matplotlib.patheffects.SimplePatchShadow(offset=(2, -2), shadow_rgbFace=None, alpha=None, rho=0.3, **kwargs) [source]

Bases: matplotlib.patheffects.AbstractPathEffect

A simple shadow via a filled patch.

Parameters:
offset : pair of floats

The offset of the shadow in points.

shadow_rgbFace : color

The shadow color.

alpha : float

The alpha transparency of the created shadow patch. Default is 0.3. http://matplotlib.1069221.n5.nabble.com/path-effects-question-td27630.html

rho : float

A scale factor to apply to the rgbFace color if shadow_rgbFace is not specified. Default is 0.3.

**kwargs

Extra keywords are stored and passed through to AbstractPathEffect._update_gc().

draw_path(renderer, gc, tpath, affine, rgbFace) [source]

Overrides the standard draw_path to add the shadow offset and necessary color changes for the shadow.

class matplotlib.patheffects.Stroke(offset=(0, 0), **kwargs) [source]

Bases: matplotlib.patheffects.AbstractPathEffect

A line based PathEffect which re-draws a stroke.

The path will be stroked with its gc updated with the given keyword arguments, i.e., the keyword arguments should be valid gc parameter values.

draw_path(renderer, gc, tpath, affine, rgbFace) [source]

draw the path with updated gc.

class matplotlib.patheffects.withSimplePatchShadow(offset=(2, -2), shadow_rgbFace=None, alpha=None, rho=0.3, **kwargs) [source]

Bases: matplotlib.patheffects.SimplePatchShadow

Adds a simple SimplePatchShadow and then draws the original Artist to avoid needing to call Normal.

Parameters:
offset : pair of floats

The offset of the shadow in points.

shadow_rgbFace : color

The shadow color.

alpha : float

The alpha transparency of the created shadow patch. Default is 0.3. http://matplotlib.1069221.n5.nabble.com/path-effects-question-td27630.html

rho : float

A scale factor to apply to the rgbFace color if shadow_rgbFace is not specified. Default is 0.3.

**kwargs

Extra keywords are stored and passed through to AbstractPathEffect._update_gc().

draw_path(renderer, gc, tpath, affine, rgbFace) [source]

Overrides the standard draw_path to add the shadow offset and necessary color changes for the shadow.

class matplotlib.patheffects.withStroke(offset=(0, 0), **kwargs) [source]

Bases: matplotlib.patheffects.Stroke

Adds a simple Stroke and then draws the original Artist to avoid needing to call Normal.

The path will be stroked with its gc updated with the given keyword arguments, i.e., the keyword arguments should be valid gc parameter values.

draw_path(renderer, gc, tpath, affine, rgbFace) [source]

draw the path with updated gc.

© 2012–2018 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/2.2.3/api/patheffects_api.html