PathEffect
Multiple Strokes
Patheffect with glow effect. |
|
Patheffect similar to Glow, but with different colors basedon the given colormap. |
ImageEffect
API
Collection of PathEffects classes.
Most of the PathEffects that inherit from ChainablePathEffect, and they can be pipelined using a | operator to make a custom patheffects. For example, “Smooth() | FillColor(‘r’)`” will smooth the path and fill the region in red.
These are list of patheffects currently available.
color modification : HLSModify, HLSaxb, ColorMatrix, FillColor, StrokeColor, FillColorFromStrokeColor, StrokeColorFromFillColor
path modification : Partial, Open, FillOnly, StrokeOnly, Smooth, SmoothFillBetween
clip modification : ClipPathFromPatch, ClipPathSelf, ClipRect
transform modification : Offset
other (non-chainable): FillImage, AlphaGradient, Glow, CmapGlow, ImageEffect
Note that PathEffects classified as “other (non-chainable)” are not inherited from ChainablePathEffect. They can be used in the pipeline but should be at the end (or immediatenly followed by ImageEffect, see below), i.e., “FillColor(‘r’) | Glow()” is okay but “Glow() | FillColor(‘r’)” is not.
The ImageEffect is very special. It should be at the end of the pipeline, even after other non-chainable PathEffects. It is a patheffect version of MPL’s agg filter. It will render the artist (w/ path effects in the pipeline) as an image (using the Agg backend), apply image processing (e.g., GaussianBlur), then place the image at the canvas.
- class mpl_visual_context.patheffects.Affine(affine=None)
Bases:
ChainablePathEffectPathEffect to apply affine trasnform the path. Note that this is applied before the affine of the path (this was intended to transform the text path)
Methods
draw_path
rotate_deg
scale
skew_deg
translate
- rotate_deg(degrees)
- scale(sx, sy=None)
- skew_deg(xShear, yShear)
- translate(tx, ty)
- class mpl_visual_context.patheffects.AlphaGradient(alphas, extent=None, bbox=None, coords=None, axes=None, **im_kw)
Bases:
GradientBaseFill the path with image of the fill color of the path, with varying transparency.
Methods
draw_path(renderer, gc, tpath, affine, rgbFace)Derived should override this method.
get_image_box
- draw_path(renderer, gc, tpath, affine, rgbFace)
Derived should override this method. The arguments are the same as
matplotlib.backend_bases.RendererBase.draw_path()except the first argument is a renderer.
- get_image_box()
- class mpl_visual_context.patheffects.ClipPathFromPatch(patch)
Bases:
ChainablePathEffectPathEffect that clips the path using a provided patch.
Methods
draw_path
- class mpl_visual_context.patheffects.ClipPathSelf
Bases:
ChainablePathEffectPathEffect that sets the clip_path to the path itself. This is useful when the path is modified down in the pipeline.
Methods
draw_path
- class mpl_visual_context.patheffects.ClipRect(ax, left=None, bottom=None, right=None, top=None, coords='data')
Bases:
ChainablePathEffectPathEffect that modifies the clip_rect using the given coordinate (and transform). In most case, the default clip_rect is the bbox of the axes.
Methods
draw_path
- class mpl_visual_context.patheffects.Clipboard(renderer=False, gc=True, tpath=True, affine=True, rgbFace=True)
Bases:
ClipboardBase,dictMethods
clear()copy()fromkeys(iterable[, value])Create a new dictionary with keys from iterable and values set to value.
get(key[, default])Return the value for key if key is in the dictionary, else default.
items()keys()pop(key[, default])If the key is not found, return the default if given; otherwise, raise a KeyError.
popitem(/)Remove and return a (key, value) pair as a 2-tuple.
setdefault(key[, default])Insert key with a value of default if key is not in the dictionary.
update([E, ]**F)If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()get_clip_path
get_path
paste
- copy() a shallow copy of D
- get_clip_path()
- get_path()
- paste()
- class mpl_visual_context.patheffects.CmapGlow(cmap, nlevel=10, diff_linewidth=5, alpha_line: float = 0.3, xoffset=0, yoffset=0)
Bases:
AbstractPathEffectPatheffect similar to Glow, but with different colors basedon the given colormap.
Methods
draw_path(renderer, gc, tpath, affine, rgbFace)Draw the path with updated gc.
- draw_path(renderer, gc, tpath, affine, rgbFace)
Draw the path with updated gc.
- class mpl_visual_context.patheffects.ColorMatrix(kind)
Bases:
ColorModifyStrokePathEffect which modifies the color in RGB space, using a predefined color matrix. Supported matrix are ‘grayscale’, ‘sepia’, ‘nightvision’, ‘warm’ and ‘cool. Both stroke and fill color are changed.
Methods
apply_to_color
draw_path
- apply_to_color(c)
- color_matrix = {'cool': array([[0.99, 0. , 0. ], [0. , 0.93, 0. ], [0. , 0. , 1.08]]), 'grayscale': array([[0.299, 0.587, 0.114], [0.299, 0.587, 0.114], [0.299, 0.587, 0.114]]), 'nightvision': array([[0.1, 0.4, 0. ], [0.3, 1. , 0.3], [0. , 0.4, 0.1]]), 'sepia': array([[0.393, 0.769, 0.189], [0.349, 0.686, 0.168], [0.272, 0.534, 0.131]]), 'warm': array([[1.06, 0. , 0. ], [0. , 1.01, 0. ], [0. , 0. , 0.93]])}
- class mpl_visual_context.patheffects.FillColor(fillcolor)
Bases:
ChainablePathEffectPathEffect to set the fill color
Methods
draw_path
- class mpl_visual_context.patheffects.FillColorFromStrokeColor
Bases:
ChainablePathEffectPathEffect to set the fill color by the stroke color
Methods
draw_path
- class mpl_visual_context.patheffects.FillImage(im, ax=None, remove_from_axes=False, alpha=None, **kwargs)
Bases:
AbstractPathEffectFill the path with the given image. It actually draws the image with its clip_path set to the path itself.
Methods
draw_path(renderer, gc, tpath, affine, rgbFace)Derived should override this method.
- draw_path(renderer, gc, tpath, affine, rgbFace)
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 mpl_visual_context.patheffects.FillOnly
Bases:
ChainablePathEffectPathEffect with only fill. This is done by setting the linewidth to 0.
Methods
draw_path
- class mpl_visual_context.patheffects.GCModify(**kwargs)
Bases:
ChainablePathEffectMethods
draw_path
- class mpl_visual_context.patheffects.Glow(n_glow_lines: int = 10, diff_linewidth: float = 1.05, alpha_line: float = 0.3, offset=(0, 0))
Bases:
AbstractPathEffectPatheffect with glow effect. Adopted from mplcybepunk. Each existing line is redrawn several times with increasing width and low alpha to create the glow effect.
Methods
draw_path(renderer, gc, tpath, affine, rgbFace)Draw the path with updated gc.
- draw_path(renderer, gc, tpath, affine, rgbFace)
Draw the path with updated gc.
- class mpl_visual_context.patheffects.Gradient(data, alpha=None, extent=None, bbox=None, coords=None, axes=None, **im_kw)
Bases:
GradientBaseMethods
draw_path(renderer, gc, tpath, affine, rgbFace)Derived should override this method.
get_image_box
- get_image_box()
- class mpl_visual_context.patheffects.HLSModify(h='100%', l='100%', s='100%', alpha='100%', dh=0, dl=0, ds=0, dalpha=0, clip_mode='clip')
Bases:
HLSaxbPathEffect which modifies the color in HLS space. Both stroke and fill color are changed.
Methods
apply_to_color
draw_path
- class mpl_visual_context.patheffects.HLSaxb(h_ab=(1, 0), l_ab=(1, 0), s_ab=(1, 0), alpha_ab=(1, 0), clip_mode='clip')
Bases:
ColorModifyStrokePathEffect which modifies the color in HLS space. Given a tuple of (a, b), the new color is defiend as h’ = a * h + b, and so on. Both stroke and fill color are changed.
Methods
apply_to_color
draw_path
- apply_to_color(c)
- class mpl_visual_context.patheffects.ImageEffect(image_effect, clip_path_getter=None, invisible_if_nill_clip_path=True)
Bases:
AbstractPathEffect,ImageEffectBaseMethods
clear
draw_path
draw_with_path_effect
get_image
get_rendered_image
init_renderer
update_gc_n_affine
- draw_path(renderer, gc, tpath, affine, rgbFace)
- get_image(renderer, gc, tpath, affine, rgbFace)
- class mpl_visual_context.patheffects.Offset(ox, oy)
Bases:
ChainablePathEffectPathEffect that offsets the path.
Methods
draw_path
- class mpl_visual_context.patheffects.Open
Bases:
ChainablePathEffectPathEffect with no closed with. This is done by replacin CLOSEPOLY code to STOP.
Methods
draw_path
- class mpl_visual_context.patheffects.Partial(start, stop)
Bases:
ChainablePathEffectPathEffect with that preserve only a part of the path. It only support lines (no bezier splines).
Methods
draw_path
- class mpl_visual_context.patheffects.PostAffine(affine=None)
Bases:
AffineSimilar to Affine, but it will be applied after the path’s affine.
Methods
draw_path
rotate_deg
scale
skew_deg
translate
- class mpl_visual_context.patheffects.Recenter(axes, ox, oy, coords='data', sign=1)
Bases:
ChainablePathEffectPathEffect that apply offsets so that the given points to be zero.
Methods
draw_path
restore
- restore()
- class mpl_visual_context.patheffects.RoundCorner(round_size=20, i_selector=None)
Bases:
ChainablePathEffectMethods
draw_path
- mpl_visual_context.patheffects.Skew(xShear, yShear)
- class mpl_visual_context.patheffects.Smooth(skip_incompatible=False)
Bases:
ChainablePathEffectPathEffect that transform the given lines to smooth bezier path. If the path is not line (not closed), the path is not changed.
Methods
draw_path
- class mpl_visual_context.patheffects.SmoothFillBetween(skip_incompatible=False, skip_first_n=0)
Bases:
SmoothPathEffect that transform a patch created by fill_between to a smooth nezier path. It assumes that the patch is consist of two lines (one for upper/left boundary another for lower/right boundary), which are smoothed separately then combined.
Methods
draw_path
- class mpl_visual_context.patheffects.StrokeColor(c)
Bases:
ChainablePathEffectPathEffect to set the stoke color
Methods
draw_path
- class mpl_visual_context.patheffects.StrokeColorFromFillColor
Bases:
ChainablePathEffectPathEffect to set the stoke color by the fill color
Methods
draw_path
- class mpl_visual_context.patheffects.StrokeOnly
Bases:
ChainablePathEffectPathEffect with only stroke. This is done by setting the fill color to None.
Methods
draw_path