W3cubDocs

/Matplotlib 3.5

matplotlib.collections

Inheritance diagram of matplotlib.collections

Classes for the efficient drawing of large collections of objects that share most properties, e.g., a large number of line segments or polygons.

The classes are not meant to be as flexible as their single element counterparts (e.g., you may not be able to select all line styles) but they are meant to be fast for common use cases (e.g., a large set of solid line segments).

classmatplotlib.collections.AsteriskPolygonCollection(numsides, rotation=0, sizes=(1,), **kwargs)[source]

Bases: matplotlib.collections.RegularPolyCollection

Draw a collection of regular asterisks with numsides points.

Parameters
numsidesint

The number of sides of the polygon.

rotationfloat

The rotation of the polygon in radians.

sizestuple of float

The area of the circle circumscribing the polygon in points^2.

**kwargs

Forwarded to Collection.

Examples

See Lasso Demo for a complete example:

offsets = np.random.rand(20, 2)
facecolors = [cm.jet(x) for x in np.random.rand(20)]

collection = RegularPolyCollection(
    numsides=5, # a pentagon
    rotation=0, sizes=(50,),
    facecolors=facecolors,
    edgecolors=("black",),
    linewidths=(1,),
    offsets=offsets,
    transOffset=ax.transData,
    )
add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters
funccallable

The callback function. It must have the signature:

def func(artist: Artist) -> Any

where artist is the calling Artist. Return values may exist but are ignored.

Returns
int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.

See also

remove_callback
autoscale()[source]

Autoscale the scalar limits on the norm instance using the current array

autoscale_None()[source]

Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None

propertyaxes

The Axes instance the artist resides in, or None.

propertycallbacksSM[source]
changed()[source]

Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.

colorbar

The last colorbar associated with this ScalarMappable. May be None.

contains(mouseevent)[source]

Test whether the mouse event occurred in the collection.

Returns bool, dict(ind=itemlist), where every item in itemlist contains the event.

convert_xunits(x)[source]

Convert x using the unit type of the xaxis.

If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.

convert_yunits(y)[source]

Convert y using the unit type of the yaxis.

If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

findobj(match=None, include_self=True)[source]

Find artist objects.

Recursively find all Artist instances contained in the artist.

Parameters
match

A filter criterion for the matches. This can be

  • None: Return all objects contained in artist.
  • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.
  • A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.

Returns
list of Artist
format_cursor_data(data)[source]

Return a string representation of data.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.

See also

get_cursor_data
get_agg_filter()[source]

Return filter function to be used for agg filter.

get_alpha()[source]

Return the alpha value used for blending - not supported on all backends.

get_animated()[source]

Return whether the artist is animated.

get_array()[source]

Return the array of values, that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.

get_capstyle()[source]
get_children()[source]

Return a list of the child Artists of this Artist.

get_clim()[source]

Return the values (min, max) that are mapped to the colormap limits.

get_clip_box()[source]

Return the clipbox.

get_clip_on()[source]

Return whether the artist uses clipping.

get_clip_path()[source]

Return the clip path.

get_cmap()[source]

Return the Colormap instance.

get_cursor_data(event)[source]

Return the cursor data for a given event.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.

Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.

The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.

Parameters
eventmatplotlib.backend_bases.MouseEvent
get_dashes()[source]

Alias for get_linestyle.

get_datalim(transData)[source]
get_ec()[source]

Alias for get_edgecolor.

get_edgecolor()[source]
get_edgecolors()[source]

Alias for get_edgecolor.

get_facecolor()[source]
get_facecolors()[source]

Alias for get_facecolor.

get_fc()[source]

Alias for get_facecolor.

get_figure()[source]

Return the Figure instance the artist belongs to.

get_fill()[source]

Return whether face is colored.

get_gid()[source]

Return the group id.

get_hatch()[source]

Return the current hatching pattern.

get_in_layout()[source]

Return boolean flag, True if artist is included in layout calculations.

E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

get_joinstyle()[source]
get_label()[source]

Return the label used for this artist in the legend.

get_linestyle()[source]
get_linestyles()[source]

Alias for get_linestyle.

get_linewidth()[source]
get_linewidths()[source]

Alias for get_linewidth.

get_ls()[source]

Alias for get_linestyle.

get_lw()[source]

Alias for get_linewidth.

get_numsides()[source]
get_offset_transform()[source]

Return the Transform instance used by this artist offset.

get_offsets()[source]

Return the offsets for the collection.

get_path_effects()[source]
get_paths()[source]
get_picker()[source]

Return the picking behavior of the artist.

The possible values are described in set_picker.

See also

set_picker, pickable, pick
get_pickradius()[source]
get_rasterized()[source]

Return whether the artist is to be rasterized.

get_rotation()[source]
get_sizes()[source]

Return the sizes ('areas') of the elements in the collection.

Returns
array

The 'area' of each element.

get_sketch_params()[source]

Return the sketch parameters for the artist.

Returns
tuple or None

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.
  • length: The length of the wiggle along the line.
  • randomness: The scale factor by which the length is shrunken or expanded.

Returns None if no sketch parameters were set.

get_snap()[source]

Return the snap setting.

See set_snap for details.

get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.

Parameters
rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

Returns
Bbox

The enclosing bounding box (in figure pixel coordinates).

get_transform()[source]

Return the Transform instance used by this artist.

get_transformed_clip_path_and_affine()[source]

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_transforms()[source]
get_url()[source]

Return the url.

get_urls()[source]

Return a list of URLs, one for each element of the collection.

The list contains None for elements without a URL. See Hyperlinks for an example.

get_visible()[source]

Return the visibility.

get_window_extent(renderer)[source]

Get the artist's bounding box in display space.

The bounding box' width and height are nonnegative.

Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

get_zorder()[source]

Return the artist's zorder.

have_units()[source]

Return whether units are set on any axis.

is_transform_set()[source]

Return whether the Artist has an explicitly set transform.

This is True after set_transform has been called.

propertymouseover

If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.

See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.

propertynorm
pchanged()[source]

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

pickable()[source]

Return whether the artist is pickable.

properties()[source]

Return a dictionary of all the properties of the artist.

remove()[source]

Remove the artist from the figure if possible.

The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

Note: relim will not see collections even if the collection was added to the axes with autolim = True.

Note: there is no support for removing the artist's legend entry.

remove_callback(oid)[source]

Remove a callback based on its observer id.

See also

add_callback
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sizes=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array

alpha

array-like or scalar or None

animated

bool

antialiased or aa or antialiaseds

bool or list of bools

array

array-like or None

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

Bbox

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of rgba tuples

edgecolor or ec or edgecolors

color or list of colors or 'face'

facecolor or facecolors or fc

color or list of colors

figure

Figure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linestyle or dashes or linestyles or ls

str or tuple or list thereof

linewidth or linewidths or lw

float or list of floats

norm

Normalize or None

offset_transform

Transform

offsets

(N, 2) or (2,) array-like

path_effects

AbstractPathEffect

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

ndarray or None

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

visible

bool

zorder

float

set_aa(aa)[source]

Alias for set_antialiased.

set_agg_filter(filter_func)[source]

Set the agg filter.

Parameters
filter_funccallable

A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

set_alpha(alpha)[source]

Set the alpha value used for blending - not supported on all backends.

Parameters
alphaarray-like or scalar or None

All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)[source]

Set whether the artist is intended to be used in an animation.

If True, the artist is excluded from regular drawing of the figure. You have to call Figure.draw_artist / Axes.draw_artist explicitly on the artist. This appoach is used to speed up animations using blitting.

See also matplotlib.animation and Faster rendering by using blitting.

Parameters
bbool
set_antialiased(aa)[source]

Set the antialiasing state for rendering.

Parameters
aabool or list of bools
set_antialiaseds(aa)[source]

Alias for set_antialiased.

set_array(A)[source]

Set the value array from array-like A.

Parameters
Aarray-like or None

The values that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.

set_capstyle(cs)[source]

Set the CapStyle for the collection (for all its elements).

Parameters
csCapStyle or {'butt', 'projecting', 'round'}
set_clim(vmin=None, vmax=None)[source]

Set the norm limits for image scaling.

Parameters
vmin, vmaxfloat

The limits.

The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.

set_clip_box(clipbox)[source]

Set the artist's clip Bbox.

Parameters
clipboxBbox
set_clip_on(b)[source]

Set whether the artist uses clipping.

When False artists will be visible outside of the axes which can lead to unexpected results.

Parameters
bbool
set_clip_path(path, transform=None)[source]

Set the artist's clip path.

Parameters
pathPatch or Path or TransformedPath or None

The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed.

transformTransform, optional

Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform.

Notes

For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter.

set_cmap(cmap)[source]

Set the colormap for luminance data.

Parameters
cmapColormap or str or None
set_color(c)[source]

Set both the edgecolor and the facecolor.

Parameters
ccolor or list of rgba tuples

See also

Collection.set_facecolor, Collection.set_edgecolor

For setting the edge or face color individually.

set_dashes(ls)[source]

Alias for set_linestyle.

set_ec(c)[source]

Alias for set_edgecolor.

set_edgecolor(c)[source]

Set the edgecolor(s) of the collection.

Parameters
ccolor or list of colors or 'face'

The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.

set_edgecolors(c)[source]

Alias for set_edgecolor.

set_facecolor(c)[source]

Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.

If c is 'none', the patch will not be filled.

Parameters
ccolor or list of colors
set_facecolors(c)[source]

Alias for set_facecolor.

set_fc(c)[source]

Alias for set_facecolor.

set_figure(fig)[source]

Set the Figure instance the artist belongs to.

Parameters
figFigure
set_gid(gid)[source]

Set the (group) id for the artist.

Parameters
gidstr
set_hatch(hatch)[source]

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.

Parameters
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_in_layout(in_layout)[source]

Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

Parameters
in_layoutbool
set_joinstyle(js)[source]

Set the JoinStyle for the collection (for all its elements).

Parameters
jsJoinStyle or {'miter', 'round', 'bevel'}
set_label(s)[source]

Set a label that will be displayed in the legend.

Parameters
sobject

s will be converted to a string by calling str.

set_linestyle(ls)[source]

Set the linestyle(s) for the collection.

linestyle

description

'-' or 'solid'

solid line

'--' or 'dashed'

dashed line

'-.' or 'dashdot'

dash-dotted line

':' or 'dotted'

dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

Parameters
lsstr or tuple or list thereof

Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle for a complete description.

set_linestyles(ls)[source]

Alias for set_linestyle.

set_linewidth(lw)[source]

Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence

Parameters
lwfloat or list of floats
set_linewidths(lw)[source]

Alias for set_linewidth.

set_ls(ls)[source]

Alias for set_linestyle.

set_lw(lw)[source]

Alias for set_linewidth.

set_norm(norm)[source]

Set the normalization instance.

Parameters
normNormalize or None

Notes

If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.

set_offset_transform(transOffset)[source]

Set the artist offset transform.

Parameters
transOffsetTransform
set_offsets(offsets)[source]

Set the offsets for the collection.

Parameters
offsets(N, 2) or (2,) array-like
set_path_effects(path_effects)[source]

Set the path effects.

Parameters
path_effectsAbstractPathEffect
set_paths()[source]
set_picker(picker)[source]

Define the picking behavior of the artist.

Parameters
pickerNone or bool or float or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).
  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
  • A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

set_pickradius(pr)[source]

Set the pick radius used for containment tests.

Parameters
prfloat

Pick radius, in points.

set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output.

Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.

This setting is ignored for pixel-based output.

See also Rasterization for vector graphics.

Parameters
rasterizedbool
set_sizes(sizes, dpi=72.0)[source]

Set the sizes of each member of the collection.

Parameters
sizesndarray or None

The size to set for each element of the collection. The value is the 'area' of the element.

dpifloat, default: 72

The dpi of the canvas.

set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.

Parameters
scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.

lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)

randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.

set_snap(snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
set_transform(t)[source]

Set the artist transform.

Parameters
tTransform
set_url(url)[source]

Set the url for the artist.

Parameters
urlstr
set_urls(urls)[source]
Parameters
urlslist of str or None

Notes

URLs are currently only implemented by the SVG backend. They are ignored by all other backends.

set_visible(b)[source]

Set the artist's visibility.

Parameters
bbool
set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.

Parameters
levelfloat
propertystale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

propertysticky_edges

x and y sticky edge lists for autoscaling.

When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.

Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.

This attribute cannot be assigned to; however, the x and y lists can be modified in place as needed.

Examples

>>> artist.sticky_edges.x[:] = (xmin, xmax)
>>> artist.sticky_edges.y[:] = (ymin, ymax)
to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x.

In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.

There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.

If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).

update(props)[source]

Update this artist's properties from the dict props.

Parameters
propsdict
update_from(other)[source]

Copy properties from other to self.

update_scalarmappable()[source]

Update colors from the scalar mappable array, if any.

Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.

zorder=0
classmatplotlib.collections.BrokenBarHCollection(xranges, yrange, **kwargs)[source]

Bases: matplotlib.collections.PolyCollection

A collection of horizontal bars spanning yrange with a sequence of xranges.

Parameters
xrangeslist of (float, float)

The sequence of (left-edge-position, width) pairs for each bar.

yrange(float, float)

The (lower-edge, height) common to all bars.

**kwargs

Forwarded to Collection.

add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters
funccallable

The callback function. It must have the signature:

def func(artist: Artist) -> Any

where artist is the calling Artist. Return values may exist but are ignored.

Returns
int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.

See also

remove_callback
autoscale()[source]

Autoscale the scalar limits on the norm instance using the current array

autoscale_None()[source]

Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None

propertyaxes

The Axes instance the artist resides in, or None.

propertycallbacksSM[source]
changed()[source]

Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.

colorbar

The last colorbar associated with this ScalarMappable. May be None.

contains(mouseevent)[source]

Test whether the mouse event occurred in the collection.

Returns bool, dict(ind=itemlist), where every item in itemlist contains the event.

convert_xunits(x)[source]

Convert x using the unit type of the xaxis.

If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.

convert_yunits(y)[source]

Convert y using the unit type of the yaxis.

If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

findobj(match=None, include_self=True)[source]

Find artist objects.

Recursively find all Artist instances contained in the artist.

Parameters
match

A filter criterion for the matches. This can be

  • None: Return all objects contained in artist.
  • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.
  • A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.

Returns
list of Artist
format_cursor_data(data)[source]

Return a string representation of data.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.

See also

get_cursor_data
get_agg_filter()[source]

Return filter function to be used for agg filter.

get_alpha()[source]

Return the alpha value used for blending - not supported on all backends.

get_animated()[source]

Return whether the artist is animated.

get_array()[source]

Return the array of values, that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.

get_capstyle()[source]
get_children()[source]

Return a list of the child Artists of this Artist.

get_clim()[source]

Return the values (min, max) that are mapped to the colormap limits.

get_clip_box()[source]

Return the clipbox.

get_clip_on()[source]

Return whether the artist uses clipping.

get_clip_path()[source]

Return the clip path.

get_cmap()[source]

Return the Colormap instance.

get_cursor_data(event)[source]

Return the cursor data for a given event.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.

Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.

The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.

Parameters
eventmatplotlib.backend_bases.MouseEvent
get_dashes()[source]

Alias for get_linestyle.

get_datalim(transData)[source]
get_ec()[source]

Alias for get_edgecolor.

get_edgecolor()[source]
get_edgecolors()[source]

Alias for get_edgecolor.

get_facecolor()[source]
get_facecolors()[source]

Alias for get_facecolor.

get_fc()[source]

Alias for get_facecolor.

get_figure()[source]

Return the Figure instance the artist belongs to.

get_fill()[source]

Return whether face is colored.

get_gid()[source]

Return the group id.

get_hatch()[source]

Return the current hatching pattern.

get_in_layout()[source]

Return boolean flag, True if artist is included in layout calculations.

E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

get_joinstyle()[source]
get_label()[source]

Return the label used for this artist in the legend.

get_linestyle()[source]
get_linestyles()[source]

Alias for get_linestyle.

get_linewidth()[source]
get_linewidths()[source]

Alias for get_linewidth.

get_ls()[source]

Alias for get_linestyle.

get_lw()[source]

Alias for get_linewidth.

get_offset_transform()[source]

Return the Transform instance used by this artist offset.

get_offsets()[source]

Return the offsets for the collection.

get_path_effects()[source]
get_paths()[source]
get_picker()[source]

Return the picking behavior of the artist.

The possible values are described in set_picker.

See also

set_picker, pickable, pick
get_pickradius()[source]
get_rasterized()[source]

Return whether the artist is to be rasterized.

get_sizes()[source]

Return the sizes ('areas') of the elements in the collection.

Returns
array

The 'area' of each element.

get_sketch_params()[source]

Return the sketch parameters for the artist.

Returns
tuple or None

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.
  • length: The length of the wiggle along the line.
  • randomness: The scale factor by which the length is shrunken or expanded.

Returns None if no sketch parameters were set.

get_snap()[source]

Return the snap setting.

See set_snap for details.

get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.

Parameters
rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

Returns
Bbox

The enclosing bounding box (in figure pixel coordinates).

get_transform()[source]

Return the Transform instance used by this artist.

get_transformed_clip_path_and_affine()[source]

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_transforms()[source]
get_url()[source]

Return the url.

get_urls()[source]

Return a list of URLs, one for each element of the collection.

The list contains None for elements without a URL. See Hyperlinks for an example.

get_visible()[source]

Return the visibility.

get_window_extent(renderer)[source]

Get the artist's bounding box in display space.

The bounding box' width and height are nonnegative.

Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

get_zorder()[source]

Return the artist's zorder.

have_units()[source]

Return whether units are set on any axis.

is_transform_set()[source]

Return whether the Artist has an explicitly set transform.

This is True after set_transform has been called.

propertymouseover

If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.

See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.

propertynorm
pchanged()[source]

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

pickable()[source]

Return whether the artist is pickable.

properties()[source]

Return a dictionary of all the properties of the artist.

remove()[source]

Remove the artist from the figure if possible.

The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

Note: relim will not see collections even if the collection was added to the axes with autolim = True.

Note: there is no support for removing the artist's legend entry.

remove_callback(oid)[source]

Remove a callback based on its observer id.

See also

add_callback
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, paths=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sizes=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, verts=<UNSET>, verts_and_codes=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array

alpha

array-like or scalar or None

animated

bool

antialiased or aa or antialiaseds

bool or list of bools

array

array-like or None

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

Bbox

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of rgba tuples

edgecolor or ec or edgecolors

color or list of colors or 'face'

facecolor or facecolors or fc

color or list of colors

figure

Figure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linestyle or dashes or linestyles or ls

str or tuple or list thereof

linewidth or linewidths or lw

float or list of floats

norm

Normalize or None

offset_transform

Transform

offsets

(N, 2) or (2,) array-like

path_effects

AbstractPathEffect

paths

list of array-like

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

ndarray or None

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

verts

list of array-like

verts_and_codes

unknown

visible

bool

zorder

float

set_aa(aa)[source]

Alias for set_antialiased.

set_agg_filter(filter_func)[source]

Set the agg filter.

Parameters
filter_funccallable

A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

set_alpha(alpha)[source]

Set the alpha value used for blending - not supported on all backends.

Parameters
alphaarray-like or scalar or None

All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)[source]

Set whether the artist is intended to be used in an animation.

If True, the artist is excluded from regular drawing of the figure. You have to call Figure.draw_artist / Axes.draw_artist explicitly on the artist. This appoach is used to speed up animations using blitting.

See also matplotlib.animation and Faster rendering by using blitting.

Parameters
bbool
set_antialiased(aa)[source]

Set the antialiasing state for rendering.

Parameters
aabool or list of bools
set_antialiaseds(aa)[source]

Alias for set_antialiased.

set_array(A)[source]

Set the value array from array-like A.

Parameters
Aarray-like or None

The values that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.

set_capstyle(cs)[source]

Set the CapStyle for the collection (for all its elements).

Parameters
csCapStyle or {'butt', 'projecting', 'round'}
set_clim(vmin=None, vmax=None)[source]

Set the norm limits for image scaling.

Parameters
vmin, vmaxfloat

The limits.

The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.

set_clip_box(clipbox)[source]

Set the artist's clip Bbox.

Parameters
clipboxBbox
set_clip_on(b)[source]

Set whether the artist uses clipping.

When False artists will be visible outside of the axes which can lead to unexpected results.

Parameters
bbool
set_clip_path(path, transform=None)[source]

Set the artist's clip path.

Parameters
pathPatch or Path or TransformedPath or None

The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed.

transformTransform, optional

Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform.

Notes

For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter.

set_cmap(cmap)[source]

Set the colormap for luminance data.

Parameters
cmapColormap or str or None
set_color(c)[source]

Set both the edgecolor and the facecolor.

Parameters
ccolor or list of rgba tuples

See also

Collection.set_facecolor, Collection.set_edgecolor

For setting the edge or face color individually.

set_dashes(ls)[source]

Alias for set_linestyle.

set_ec(c)[source]

Alias for set_edgecolor.

set_edgecolor(c)[source]

Set the edgecolor(s) of the collection.

Parameters
ccolor or list of colors or 'face'

The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.

set_edgecolors(c)[source]

Alias for set_edgecolor.

set_facecolor(c)[source]

Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.

If c is 'none', the patch will not be filled.

Parameters
ccolor or list of colors
set_facecolors(c)[source]

Alias for set_facecolor.

set_fc(c)[source]

Alias for set_facecolor.

set_figure(fig)[source]

Set the Figure instance the artist belongs to.

Parameters
figFigure
set_gid(gid)[source]

Set the (group) id for the artist.

Parameters
gidstr
set_hatch(hatch)[source]

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.

Parameters
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_in_layout(in_layout)[source]

Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

Parameters
in_layoutbool
set_joinstyle(js)[source]

Set the JoinStyle for the collection (for all its elements).

Parameters
jsJoinStyle or {'miter', 'round', 'bevel'}
set_label(s)[source]

Set a label that will be displayed in the legend.

Parameters
sobject

s will be converted to a string by calling str.

set_linestyle(ls)[source]

Set the linestyle(s) for the collection.

linestyle

description

'-' or 'solid'

solid line

'--' or 'dashed'

dashed line

'-.' or 'dashdot'

dash-dotted line

':' or 'dotted'

dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

Parameters
lsstr or tuple or list thereof

Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle for a complete description.

set_linestyles(ls)[source]

Alias for set_linestyle.

set_linewidth(lw)[source]

Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence

Parameters
lwfloat or list of floats
set_linewidths(lw)[source]

Alias for set_linewidth.

set_ls(ls)[source]

Alias for set_linestyle.

set_lw(lw)[source]

Alias for set_linewidth.

set_norm(norm)[source]

Set the normalization instance.

Parameters
normNormalize or None

Notes

If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.

set_offset_transform(transOffset)[source]

Set the artist offset transform.

Parameters
transOffsetTransform
set_offsets(offsets)[source]

Set the offsets for the collection.

Parameters
offsets(N, 2) or (2,) array-like
set_path_effects(path_effects)[source]

Set the path effects.

Parameters
path_effectsAbstractPathEffect
set_paths(verts, closed=True)[source]

Set the vertices of the polygons.

Parameters
vertslist of array-like

The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).

closedbool, default: True

Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.

set_picker(picker)[source]

Define the picking behavior of the artist.

Parameters
pickerNone or bool or float or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).
  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
  • A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

set_pickradius(pr)[source]

Set the pick radius used for containment tests.

Parameters
prfloat

Pick radius, in points.

set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output.

Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.

This setting is ignored for pixel-based output.

See also Rasterization for vector graphics.

Parameters
rasterizedbool
set_sizes(sizes, dpi=72.0)[source]

Set the sizes of each member of the collection.

Parameters
sizesndarray or None

The size to set for each element of the collection. The value is the 'area' of the element.

dpifloat, default: 72

The dpi of the canvas.

set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.

Parameters
scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.

lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)

randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.

set_snap(snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
set_transform(t)[source]

Set the artist transform.

Parameters
tTransform
set_url(url)[source]

Set the url for the artist.

Parameters
urlstr
set_urls(urls)[source]
Parameters
urlslist of str or None

Notes

URLs are currently only implemented by the SVG backend. They are ignored by all other backends.

set_verts(verts, closed=True)[source]

Set the vertices of the polygons.

Parameters
vertslist of array-like

The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).

closedbool, default: True

Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.

set_verts_and_codes(verts, codes)[source]

Initialize vertices with path codes.

set_visible(b)[source]

Set the artist's visibility.

Parameters
bbool
set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.

Parameters
levelfloat
classmethodspan_where(x, ymin, ymax, where, **kwargs)[source]

Return a BrokenBarHCollection that plots horizontal bars from over the regions in x where where is True. The bars range on the y-axis from ymin to ymax

kwargs are passed on to the collection.

propertystale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

propertysticky_edges

x and y sticky edge lists for autoscaling.

When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.

Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.

This attribute cannot be assigned to; however, the x and y lists can be modified in place as needed.

Examples

>>> artist.sticky_edges.x[:] = (xmin, xmax)
>>> artist.sticky_edges.y[:] = (ymin, ymax)
to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x.

In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.

There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.

If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).

update(props)[source]

Update this artist's properties from the dict props.

Parameters
propsdict
update_from(other)[source]

Copy properties from other to self.

update_scalarmappable()[source]

Update colors from the scalar mappable array, if any.

Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.

zorder=0
classmatplotlib.collections.CircleCollection(sizes, **kwargs)[source]

Bases: matplotlib.collections._CollectionWithSizes

A collection of circles, drawn using splines.

Parameters
sizesfloat or array-like

The area of each circle in points^2.

**kwargs

Forwarded to Collection.

add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters
funccallable

The callback function. It must have the signature:

def func(artist: Artist) -> Any

where artist is the calling Artist. Return values may exist but are ignored.

Returns
int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.

See also

remove_callback
autoscale()[source]

Autoscale the scalar limits on the norm instance using the current array

autoscale_None()[source]

Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None

propertyaxes

The Axes instance the artist resides in, or None.

propertycallbacksSM[source]
changed()[source]

Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.

colorbar

The last colorbar associated with this ScalarMappable. May be None.

contains(mouseevent)[source]

Test whether the mouse event occurred in the collection.

Returns bool, dict(ind=itemlist), where every item in itemlist contains the event.

convert_xunits(x)[source]

Convert x using the unit type of the xaxis.

If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.

convert_yunits(y)[source]

Convert y using the unit type of the yaxis.

If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

findobj(match=None, include_self=True)[source]

Find artist objects.

Recursively find all Artist instances contained in the artist.

Parameters
match

A filter criterion for the matches. This can be

  • None: Return all objects contained in artist.
  • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.
  • A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.

Returns
list of Artist
format_cursor_data(data)[source]

Return a string representation of data.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.

See also

get_cursor_data
get_agg_filter()[source]

Return filter function to be used for agg filter.

get_alpha()[source]

Return the alpha value used for blending - not supported on all backends.

get_animated()[source]

Return whether the artist is animated.

get_array()[source]

Return the array of values, that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.

get_capstyle()[source]
get_children()[source]

Return a list of the child Artists of this Artist.

get_clim()[source]

Return the values (min, max) that are mapped to the colormap limits.

get_clip_box()[source]

Return the clipbox.

get_clip_on()[source]

Return whether the artist uses clipping.

get_clip_path()[source]

Return the clip path.

get_cmap()[source]

Return the Colormap instance.

get_cursor_data(event)[source]

Return the cursor data for a given event.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.

Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.

The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.

Parameters
eventmatplotlib.backend_bases.MouseEvent
get_dashes()[source]

Alias for get_linestyle.

get_datalim(transData)[source]
get_ec()[source]

Alias for get_edgecolor.

get_edgecolor()[source]
get_edgecolors()[source]

Alias for get_edgecolor.

get_facecolor()[source]
get_facecolors()[source]

Alias for get_facecolor.

get_fc()[source]

Alias for get_facecolor.

get_figure()[source]

Return the Figure instance the artist belongs to.

get_fill()[source]

Return whether face is colored.

get_gid()[source]

Return the group id.

get_hatch()[source]

Return the current hatching pattern.

get_in_layout()[source]

Return boolean flag, True if artist is included in layout calculations.

E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

get_joinstyle()[source]
get_label()[source]

Return the label used for this artist in the legend.

get_linestyle()[source]
get_linestyles()[source]

Alias for get_linestyle.

get_linewidth()[source]
get_linewidths()[source]

Alias for get_linewidth.

get_ls()[source]

Alias for get_linestyle.

get_lw()[source]

Alias for get_linewidth.

get_offset_transform()[source]

Return the Transform instance used by this artist offset.

get_offsets()[source]

Return the offsets for the collection.

get_path_effects()[source]
get_paths()[source]
get_picker()[source]

Return the picking behavior of the artist.

The possible values are described in set_picker.

See also

set_picker, pickable, pick
get_pickradius()[source]
get_rasterized()[source]

Return whether the artist is to be rasterized.

get_sizes()[source]

Return the sizes ('areas') of the elements in the collection.

Returns
array

The 'area' of each element.

get_sketch_params()[source]

Return the sketch parameters for the artist.

Returns
tuple or None

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.
  • length: The length of the wiggle along the line.
  • randomness: The scale factor by which the length is shrunken or expanded.

Returns None if no sketch parameters were set.

get_snap()[source]

Return the snap setting.

See set_snap for details.

get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.

Parameters
rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

Returns
Bbox

The enclosing bounding box (in figure pixel coordinates).

get_transform()[source]

Return the Transform instance used by this artist.

get_transformed_clip_path_and_affine()[source]

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_transforms()[source]
get_url()[source]

Return the url.

get_urls()[source]

Return a list of URLs, one for each element of the collection.

The list contains None for elements without a URL. See Hyperlinks for an example.

get_visible()[source]

Return the visibility.

get_window_extent(renderer)[source]

Get the artist's bounding box in display space.

The bounding box' width and height are nonnegative.

Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

get_zorder()[source]

Return the artist's zorder.

have_units()[source]

Return whether units are set on any axis.

is_transform_set()[source]

Return whether the Artist has an explicitly set transform.

This is True after set_transform has been called.

propertymouseover

If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.

See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.

propertynorm
pchanged()[source]

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

pickable()[source]

Return whether the artist is pickable.

properties()[source]

Return a dictionary of all the properties of the artist.

remove()[source]

Remove the artist from the figure if possible.

The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

Note: relim will not see collections even if the collection was added to the axes with autolim = True.

Note: there is no support for removing the artist's legend entry.

remove_callback(oid)[source]

Remove a callback based on its observer id.

See also

add_callback
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sizes=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array

alpha

array-like or scalar or None

animated

bool

antialiased or aa or antialiaseds

bool or list of bools

array

array-like or None

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

Bbox

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of rgba tuples

edgecolor or ec or edgecolors

color or list of colors or 'face'

facecolor or facecolors or fc

color or list of colors

figure

Figure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linestyle or dashes or linestyles or ls

str or tuple or list thereof

linewidth or linewidths or lw

float or list of floats

norm

Normalize or None

offset_transform

Transform

offsets

(N, 2) or (2,) array-like

path_effects

AbstractPathEffect

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

ndarray or None

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

visible

bool

zorder

float

set_aa(aa)[source]

Alias for set_antialiased.

set_agg_filter(filter_func)[source]

Set the agg filter.

Parameters
filter_funccallable

A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

set_alpha(alpha)[source]

Set the alpha value used for blending - not supported on all backends.

Parameters
alphaarray-like or scalar or None

All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)[source]

Set whether the artist is intended to be used in an animation.

If True, the artist is excluded from regular drawing of the figure. You have to call Figure.draw_artist / Axes.draw_artist explicitly on the artist. This appoach is used to speed up animations using blitting.

See also matplotlib.animation and Faster rendering by using blitting.

Parameters
bbool
set_antialiased(aa)[source]

Set the antialiasing state for rendering.

Parameters
aabool or list of bools
set_antialiaseds(aa)[source]

Alias for set_antialiased.

set_array(A)[source]

Set the value array from array-like A.

Parameters
Aarray-like or None

The values that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.

set_capstyle(cs)[source]

Set the CapStyle for the collection (for all its elements).

Parameters
csCapStyle or {'butt', 'projecting', 'round'}
set_clim(vmin=None, vmax=None)[source]

Set the norm limits for image scaling.

Parameters
vmin, vmaxfloat

The limits.

The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.

set_clip_box(clipbox)[source]

Set the artist's clip Bbox.

Parameters
clipboxBbox
set_clip_on(b)[source]

Set whether the artist uses clipping.

When False artists will be visible outside of the axes which can lead to unexpected results.

Parameters
bbool
set_clip_path(path, transform=None)[source]

Set the artist's clip path.

Parameters
pathPatch or Path or TransformedPath or None

The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed.

transformTransform, optional

Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform.

Notes

For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter.

set_cmap(cmap)[source]

Set the colormap for luminance data.

Parameters
cmapColormap or str or None
set_color(c)[source]

Set both the edgecolor and the facecolor.

Parameters
ccolor or list of rgba tuples

See also

Collection.set_facecolor, Collection.set_edgecolor

For setting the edge or face color individually.

set_dashes(ls)[source]

Alias for set_linestyle.

set_ec(c)[source]

Alias for set_edgecolor.

set_edgecolor(c)[source]

Set the edgecolor(s) of the collection.

Parameters
ccolor or list of colors or 'face'

The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.

set_edgecolors(c)[source]

Alias for set_edgecolor.

set_facecolor(c)[source]

Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.

If c is 'none', the patch will not be filled.

Parameters
ccolor or list of colors
set_facecolors(c)[source]

Alias for set_facecolor.

set_fc(c)[source]

Alias for set_facecolor.

set_figure(fig)[source]

Set the Figure instance the artist belongs to.

Parameters
figFigure
set_gid(gid)[source]

Set the (group) id for the artist.

Parameters
gidstr
set_hatch(hatch)[source]

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.

Parameters
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_in_layout(in_layout)[source]

Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

Parameters
in_layoutbool
set_joinstyle(js)[source]

Set the JoinStyle for the collection (for all its elements).

Parameters
jsJoinStyle or {'miter', 'round', 'bevel'}
set_label(s)[source]

Set a label that will be displayed in the legend.

Parameters
sobject

s will be converted to a string by calling str.

set_linestyle(ls)[source]

Set the linestyle(s) for the collection.

linestyle

description

'-' or 'solid'

solid line

'--' or 'dashed'

dashed line

'-.' or 'dashdot'

dash-dotted line

':' or 'dotted'

dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

Parameters
lsstr or tuple or list thereof

Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle for a complete description.

set_linestyles(ls)[source]

Alias for set_linestyle.

set_linewidth(lw)[source]

Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence

Parameters
lwfloat or list of floats
set_linewidths(lw)[source]

Alias for set_linewidth.

set_ls(ls)[source]

Alias for set_linestyle.

set_lw(lw)[source]

Alias for set_linewidth.

set_norm(norm)[source]

Set the normalization instance.

Parameters
normNormalize or None

Notes

If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.

set_offset_transform(transOffset)[source]

Set the artist offset transform.

Parameters
transOffsetTransform
set_offsets(offsets)[source]

Set the offsets for the collection.

Parameters
offsets(N, 2) or (2,) array-like
set_path_effects(path_effects)[source]

Set the path effects.

Parameters
path_effectsAbstractPathEffect
set_paths()[source]
set_picker(picker)[source]

Define the picking behavior of the artist.

Parameters
pickerNone or bool or float or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).
  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
  • A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

set_pickradius(pr)[source]

Set the pick radius used for containment tests.

Parameters
prfloat

Pick radius, in points.

set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output.

Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.

This setting is ignored for pixel-based output.

See also Rasterization for vector graphics.

Parameters
rasterizedbool
set_sizes(sizes, dpi=72.0)[source]

Set the sizes of each member of the collection.

Parameters
sizesndarray or None

The size to set for each element of the collection. The value is the 'area' of the element.

dpifloat, default: 72

The dpi of the canvas.

set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.

Parameters
scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.

lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)

randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.

set_snap(snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
set_transform(t)[source]

Set the artist transform.

Parameters
tTransform
set_url(url)[source]

Set the url for the artist.

Parameters
urlstr
set_urls(urls)[source]
Parameters
urlslist of str or None

Notes

URLs are currently only implemented by the SVG backend. They are ignored by all other backends.

set_visible(b)[source]

Set the artist's visibility.

Parameters
bbool
set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.

Parameters
levelfloat
propertystale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

propertysticky_edges

x and y sticky edge lists for autoscaling.

When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.

Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.

This attribute cannot be assigned to; however, the x and y lists can be modified in place as needed.

Examples

>>> artist.sticky_edges.x[:] = (xmin, xmax)
>>> artist.sticky_edges.y[:] = (ymin, ymax)
to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x.

In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.

There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.

If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).

update(props)[source]

Update this artist's properties from the dict props.

Parameters
propsdict
update_from(other)[source]

Copy properties from other to self.

update_scalarmappable()[source]

Update colors from the scalar mappable array, if any.

Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.

zorder=0
classmatplotlib.collections.Collection(edgecolors=None, facecolors=None, linewidths=None, linestyles='solid', capstyle=None, joinstyle=None, antialiaseds=None, offsets=None, transOffset=None, norm=None, cmap=None, pickradius=5.0, hatch=None, urls=None, *, zorder=1, **kwargs)[source]

Bases: matplotlib.artist.Artist, matplotlib.cm.ScalarMappable

Base class for Collections. Must be subclassed to be usable.

A Collection represents a sequence of Patches that can be drawn more efficiently together than individually. For example, when a single path is being drawn repeatedly at different offsets, the renderer can typically execute a draw_marker() call much more efficiently than a series of repeated calls to draw_path() with the offsets put in one-by-one.

Most properties of a collection can be configured per-element. Therefore, Collections have "plural" versions of many of the properties of a Patch (e.g. Collection.get_paths instead of Patch.get_path). Exceptions are the zorder, hatch, pickradius, capstyle and joinstyle properties, which can only be set globally for the whole collection.

Besides these exceptions, all properties can be specified as single values (applying to all elements) or sequences of values. The property of the ith element of the collection is:

prop[i % len(prop)]

Each Collection can optionally be used as its own ScalarMappable by passing the norm and cmap parameters to its constructor. If the Collection's ScalarMappable matrix _A has been set (via a call to Collection.set_array), then at draw time this internal scalar mappable will be used to set the facecolors and edgecolors, ignoring those that were manually passed in.

Parameters
edgecolorscolor or list of colors, default: rcParams["patch.edgecolor"] (default: 'black')

Edge color for each patch making up the collection. The special value 'face' can be passed to make the edgecolor match the facecolor.

facecolorscolor or list of colors, default: rcParams["patch.facecolor"] (default: 'C0')

Face color for each patch making up the collection.

linewidthsfloat or list of floats, default: rcParams["patch.linewidth"] (default: 1.0)

Line width for each patch making up the collection.

linestylesstr or tuple or list thereof, default: 'solid'

Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink lengths in points. For examples, see Linestyles.

capstyleCapStyle-like, default: rcParams["patch.capstyle"]

Style to use for capping lines for all paths in the collection. Allowed values are {'butt', 'projecting', 'round'}.

joinstyleJoinStyle-like, default: rcParams["patch.joinstyle"]

Style to use for joining lines for all paths in the collection. Allowed values are {'miter', 'round', 'bevel'}.

antialiasedsbool or list of bool, default: rcParams["patch.antialiased"] (default: True)

Whether each patch in the collection should be drawn with antialiasing.

offsets(float, float) or list thereof, default: (0, 0)

A vector by which to translate each patch after rendering (default is no translation). The translation is performed in screen (pixel) coordinates (i.e. after the Artist's transform is applied).

transOffsetTransform, default: IdentityTransform

A single transform which will be applied to each offsets vector before it is used.

normNormalize, optional

Forwarded to ScalarMappable. The default of None means that the first draw call will set vmin and vmax using the minimum and maximum values of the data.

cmapColormap, optional

Forwarded to ScalarMappable. The default of None will result in rcParams["image.cmap"] (default: 'viridis') being used.

hatchstr, optional

Hatching pattern to use in filled paths, if any. Valid strings are ['/', '', '|', '-', '+', 'x', 'o', 'O', '.', '*']. See Hatch style reference for the meaning of each hatch type.

pickradiusfloat, default: 5.0

If pickradius <= 0, then Collection.contains will return True whenever the test point is inside of one of the polygons formed by the control points of a Path in the Collection. On the other hand, if it is greater than 0, then we instead check if the test point is contained in a stroke of width 2*pickradius following any of the Paths in the Collection.

urlslist of str, default: None

A URL for each patch to link to once drawn. Currently only works for the SVG backend. See Hyperlinks for examples.

zorderfloat, default: 1

The drawing order, shared by all Patches in the Collection. See Zorder Demo for all defaults and examples.

add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters
funccallable

The callback function. It must have the signature:

def func(artist: Artist) -> Any

where artist is the calling Artist. Return values may exist but are ignored.

Returns
int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.

See also

remove_callback
autoscale()[source]

Autoscale the scalar limits on the norm instance using the current array

autoscale_None()[source]

Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None

propertyaxes

The Axes instance the artist resides in, or None.

propertycallbacksSM[source]
changed()[source]

Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.

colorbar

The last colorbar associated with this ScalarMappable. May be None.

contains(mouseevent)[source]

Test whether the mouse event occurred in the collection.

Returns bool, dict(ind=itemlist), where every item in itemlist contains the event.

convert_xunits(x)[source]

Convert x using the unit type of the xaxis.

If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.

convert_yunits(y)[source]

Convert y using the unit type of the yaxis.

If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

findobj(match=None, include_self=True)[source]

Find artist objects.

Recursively find all Artist instances contained in the artist.

Parameters
match

A filter criterion for the matches. This can be

  • None: Return all objects contained in artist.
  • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.
  • A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.

Returns
list of Artist
format_cursor_data(data)[source]

Return a string representation of data.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.

See also

get_cursor_data
get_agg_filter()[source]

Return filter function to be used for agg filter.

get_alpha()[source]

Return the alpha value used for blending - not supported on all backends.

get_animated()[source]

Return whether the artist is animated.

get_array()[source]

Return the array of values, that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.

get_capstyle()[source]
get_children()[source]

Return a list of the child Artists of this Artist.

get_clim()[source]

Return the values (min, max) that are mapped to the colormap limits.

get_clip_box()[source]

Return the clipbox.

get_clip_on()[source]

Return whether the artist uses clipping.

get_clip_path()[source]

Return the clip path.

get_cmap()[source]

Return the Colormap instance.

get_cursor_data(event)[source]

Return the cursor data for a given event.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.

Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.

The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.

Parameters
eventmatplotlib.backend_bases.MouseEvent
get_dashes()[source]

Alias for get_linestyle.

get_datalim(transData)[source]
get_ec()[source]

Alias for get_edgecolor.

get_edgecolor()[source]
get_edgecolors()[source]

Alias for get_edgecolor.

get_facecolor()[source]
get_facecolors()[source]

Alias for get_facecolor.

get_fc()[source]

Alias for get_facecolor.

get_figure()[source]

Return the Figure instance the artist belongs to.

get_fill()[source]

Return whether face is colored.

get_gid()[source]

Return the group id.

get_hatch()[source]

Return the current hatching pattern.

get_in_layout()[source]

Return boolean flag, True if artist is included in layout calculations.

E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

get_joinstyle()[source]
get_label()[source]

Return the label used for this artist in the legend.

get_linestyle()[source]
get_linestyles()[source]

Alias for get_linestyle.

get_linewidth()[source]
get_linewidths()[source]

Alias for get_linewidth.

get_ls()[source]

Alias for get_linestyle.

get_lw()[source]

Alias for get_linewidth.

get_offset_transform()[source]

Return the Transform instance used by this artist offset.

get_offsets()[source]

Return the offsets for the collection.

get_path_effects()[source]
get_paths()[source]
get_picker()[source]

Return the picking behavior of the artist.

The possible values are described in set_picker.

See also

set_picker, pickable, pick
get_pickradius()[source]
get_rasterized()[source]

Return whether the artist is to be rasterized.

get_sketch_params()[source]

Return the sketch parameters for the artist.

Returns
tuple or None

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.
  • length: The length of the wiggle along the line.
  • randomness: The scale factor by which the length is shrunken or expanded.

Returns None if no sketch parameters were set.

get_snap()[source]

Return the snap setting.

See set_snap for details.

get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.

Parameters
rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

Returns
Bbox

The enclosing bounding box (in figure pixel coordinates).

get_transform()[source]

Return the Transform instance used by this artist.

get_transformed_clip_path_and_affine()[source]

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_transforms()[source]
get_url()[source]

Return the url.

get_urls()[source]

Return a list of URLs, one for each element of the collection.

The list contains None for elements without a URL. See Hyperlinks for an example.

get_visible()[source]

Return the visibility.

get_window_extent(renderer)[source]

Get the artist's bounding box in display space.

The bounding box' width and height are nonnegative.

Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

get_zorder()[source]

Return the artist's zorder.

have_units()[source]

Return whether units are set on any axis.

is_transform_set()[source]

Return whether the Artist has an explicitly set transform.

This is True after set_transform has been called.

propertymouseover

If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.

See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.

propertynorm
pchanged()[source]

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

pickable()[source]

Return whether the artist is pickable.

properties()[source]

Return a dictionary of all the properties of the artist.

remove()[source]

Remove the artist from the figure if possible.

The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

Note: relim will not see collections even if the collection was added to the axes with autolim = True.

Note: there is no support for removing the artist's legend entry.

remove_callback(oid)[source]

Remove a callback based on its observer id.

See also

add_callback
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array

alpha

array-like or scalar or None

animated

bool

antialiased

bool or list of bools

array

array-like or None

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

Bbox

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of rgba tuples

edgecolor

color or list of colors or 'face'

facecolor

color or list of colors

figure

Figure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linestyle

str or tuple or list thereof

linewidth

float or list of floats

norm

Normalize or None

offset_transform

Transform

offsets

(N, 2) or (2,) array-like

path_effects

AbstractPathEffect

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

visible

bool

zorder

float

set_aa(aa)[source]

Alias for set_antialiased.

set_agg_filter(filter_func)[source]

Set the agg filter.

Parameters
filter_funccallable

A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

set_alpha(alpha)[source]

Set the alpha value used for blending - not supported on all backends.

Parameters
alphaarray-like or scalar or None

All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)[source]

Set whether the artist is intended to be used in an animation.

If True, the artist is excluded from regular drawing of the figure. You have to call Figure.draw_artist / Axes.draw_artist explicitly on the artist. This appoach is used to speed up animations using blitting.

See also matplotlib.animation and Faster rendering by using blitting.

Parameters
bbool
set_antialiased(aa)[source]

Set the antialiasing state for rendering.

Parameters
aabool or list of bools
set_antialiaseds(aa)[source]

Alias for set_antialiased.

set_array(A)[source]

Set the value array from array-like A.

Parameters
Aarray-like or None

The values that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.

set_capstyle(cs)[source]

Set the CapStyle for the collection (for all its elements).

Parameters
csCapStyle or {'butt', 'projecting', 'round'}
set_clim(vmin=None, vmax=None)[source]

Set the norm limits for image scaling.

Parameters
vmin, vmaxfloat

The limits.

The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.

set_clip_box(clipbox)[source]

Set the artist's clip Bbox.

Parameters
clipboxBbox
set_clip_on(b)[source]

Set whether the artist uses clipping.

When False artists will be visible outside of the axes which can lead to unexpected results.

Parameters
bbool
set_clip_path(path, transform=None)[source]

Set the artist's clip path.

Parameters
pathPatch or Path or TransformedPath or None

The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed.

transformTransform, optional

Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform.

Notes

For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter.

set_cmap(cmap)[source]

Set the colormap for luminance data.

Parameters
cmapColormap or str or None
set_color(c)[source]

Set both the edgecolor and the facecolor.

Parameters
ccolor or list of rgba tuples

See also

Collection.set_facecolor, Collection.set_edgecolor

For setting the edge or face color individually.

set_dashes(ls)[source]

Alias for set_linestyle.

set_ec(c)[source]

Alias for set_edgecolor.

set_edgecolor(c)[source]

Set the edgecolor(s) of the collection.

Parameters
ccolor or list of colors or 'face'

The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.

set_edgecolors(c)[source]

Alias for set_edgecolor.

set_facecolor(c)[source]

Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.

If c is 'none', the patch will not be filled.

Parameters
ccolor or list of colors
set_facecolors(c)[source]

Alias for set_facecolor.

set_fc(c)[source]

Alias for set_facecolor.

set_figure(fig)[source]

Set the Figure instance the artist belongs to.

Parameters
figFigure
set_gid(gid)[source]

Set the (group) id for the artist.

Parameters
gidstr
set_hatch(hatch)[source]

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.

Parameters
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_in_layout(in_layout)[source]

Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

Parameters
in_layoutbool
set_joinstyle(js)[source]

Set the JoinStyle for the collection (for all its elements).

Parameters
jsJoinStyle or {'miter', 'round', 'bevel'}
set_label(s)[source]

Set a label that will be displayed in the legend.

Parameters
sobject

s will be converted to a string by calling str.

set_linestyle(ls)[source]

Set the linestyle(s) for the collection.

linestyle

description

'-' or 'solid'

solid line

'--' or 'dashed'

dashed line

'-.' or 'dashdot'

dash-dotted line

':' or 'dotted'

dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

Parameters
lsstr or tuple or list thereof

Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle for a complete description.

set_linestyles(ls)[source]

Alias for set_linestyle.

set_linewidth(lw)[source]

Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence

Parameters
lwfloat or list of floats
set_linewidths(lw)[source]

Alias for set_linewidth.

set_ls(ls)[source]

Alias for set_linestyle.

set_lw(lw)[source]

Alias for set_linewidth.

set_norm(norm)[source]

Set the normalization instance.

Parameters
normNormalize or None

Notes

If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.

set_offset_transform(transOffset)[source]

Set the artist offset transform.

Parameters
transOffsetTransform
set_offsets(offsets)[source]

Set the offsets for the collection.

Parameters
offsets(N, 2) or (2,) array-like
set_path_effects(path_effects)[source]

Set the path effects.

Parameters
path_effectsAbstractPathEffect
set_paths()[source]
set_picker(picker)[source]

Define the picking behavior of the artist.

Parameters
pickerNone or bool or float or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).
  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
  • A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

set_pickradius(pr)[source]

Set the pick radius used for containment tests.

Parameters
prfloat

Pick radius, in points.

set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output.

Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.

This setting is ignored for pixel-based output.

See also Rasterization for vector graphics.

Parameters
rasterizedbool
set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.

Parameters
scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.

lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)

randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.

set_snap(snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
set_transform(t)[source]

Set the artist transform.

Parameters
tTransform
set_url(url)[source]

Set the url for the artist.

Parameters
urlstr
set_urls(urls)[source]
Parameters
urlslist of str or None

Notes

URLs are currently only implemented by the SVG backend. They are ignored by all other backends.

set_visible(b)[source]

Set the artist's visibility.

Parameters
bbool
set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.

Parameters
levelfloat
propertystale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

propertysticky_edges

x and y sticky edge lists for autoscaling.

When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.

Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.

This attribute cannot be assigned to; however, the x and y lists can be modified in place as needed.

Examples

>>> artist.sticky_edges.x[:] = (xmin, xmax)
>>> artist.sticky_edges.y[:] = (ymin, ymax)
to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x.

In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.

There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.

If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).

update(props)[source]

Update this artist's properties from the dict props.

Parameters
propsdict
update_from(other)[source]

Copy properties from other to self.

update_scalarmappable()[source]

Update colors from the scalar mappable array, if any.

Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.

zorder=0
classmatplotlib.collections.EllipseCollection(widths, heights, angles, units='points', **kwargs)[source]

Bases: matplotlib.collections.Collection

A collection of ellipses, drawn using splines.

Parameters
widthsarray-like

The lengths of the first axes (e.g., major axis lengths).

heightsarray-like

The lengths of second axes.

anglesarray-like

The angles of the first axes, degrees CCW from the x-axis.

units{'points', 'inches', 'dots', 'width', 'height', 'x', 'y', 'xy'}

The units in which majors and minors are given; 'width' and 'height' refer to the dimensions of the axes, while 'x' and 'y' refer to the offsets data units. 'xy' differs from all others in that the angle as plotted varies with the aspect ratio, and equals the specified angle only when the aspect ratio is unity. Hence it behaves the same as the Ellipse with axes.transData as its transform.

**kwargs

Forwarded to Collection.

add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters
funccallable

The callback function. It must have the signature:

def func(artist: Artist) -> Any

where artist is the calling Artist. Return values may exist but are ignored.

Returns
int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.

See also

remove_callback
autoscale()[source]

Autoscale the scalar limits on the norm instance using the current array

autoscale_None()[source]

Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None

propertyaxes

The Axes instance the artist resides in, or None.

propertycallbacksSM[source]
changed()[source]

Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.

colorbar

The last colorbar associated with this ScalarMappable. May be None.

contains(mouseevent)[source]

Test whether the mouse event occurred in the collection.

Returns bool, dict(ind=itemlist), where every item in itemlist contains the event.

convert_xunits(x)[source]

Convert x using the unit type of the xaxis.

If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.

convert_yunits(y)[source]

Convert y using the unit type of the yaxis.

If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

findobj(match=None, include_self=True)[source]

Find artist objects.

Recursively find all Artist instances contained in the artist.

Parameters
match

A filter criterion for the matches. This can be

  • None: Return all objects contained in artist.
  • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.
  • A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.

Returns
list of Artist
format_cursor_data(data)[source]

Return a string representation of data.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.

See also

get_cursor_data
get_agg_filter()[source]

Return filter function to be used for agg filter.

get_alpha()[source]

Return the alpha value used for blending - not supported on all backends.

get_animated()[source]

Return whether the artist is animated.

get_array()[source]

Return the array of values, that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.

get_capstyle()[source]
get_children()[source]

Return a list of the child Artists of this Artist.

get_clim()[source]

Return the values (min, max) that are mapped to the colormap limits.

get_clip_box()[source]

Return the clipbox.

get_clip_on()[source]

Return whether the artist uses clipping.

get_clip_path()[source]

Return the clip path.

get_cmap()[source]

Return the Colormap instance.

get_cursor_data(event)[source]

Return the cursor data for a given event.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.

Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.

The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.

Parameters
eventmatplotlib.backend_bases.MouseEvent
get_dashes()[source]

Alias for get_linestyle.

get_datalim(transData)[source]
get_ec()[source]

Alias for get_edgecolor.

get_edgecolor()[source]
get_edgecolors()[source]

Alias for get_edgecolor.

get_facecolor()[source]
get_facecolors()[source]

Alias for get_facecolor.

get_fc()[source]

Alias for get_facecolor.

get_figure()[source]

Return the Figure instance the artist belongs to.

get_fill()[source]

Return whether face is colored.

get_gid()[source]

Return the group id.

get_hatch()[source]

Return the current hatching pattern.

get_in_layout()[source]

Return boolean flag, True if artist is included in layout calculations.

E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

get_joinstyle()[source]
get_label()[source]

Return the label used for this artist in the legend.

get_linestyle()[source]
get_linestyles()[source]

Alias for get_linestyle.

get_linewidth()[source]
get_linewidths()[source]

Alias for get_linewidth.

get_ls()[source]

Alias for get_linestyle.

get_lw()[source]

Alias for get_linewidth.

get_offset_transform()[source]

Return the Transform instance used by this artist offset.

get_offsets()[source]

Return the offsets for the collection.

get_path_effects()[source]
get_paths()[source]
get_picker()[source]

Return the picking behavior of the artist.

The possible values are described in set_picker.

See also

set_picker, pickable, pick
get_pickradius()[source]
get_rasterized()[source]

Return whether the artist is to be rasterized.

get_sketch_params()[source]

Return the sketch parameters for the artist.

Returns
tuple or None

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.
  • length: The length of the wiggle along the line.
  • randomness: The scale factor by which the length is shrunken or expanded.

Returns None if no sketch parameters were set.

get_snap()[source]

Return the snap setting.

See set_snap for details.

get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.

Parameters
rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

Returns
Bbox

The enclosing bounding box (in figure pixel coordinates).

get_transform()[source]

Return the Transform instance used by this artist.

get_transformed_clip_path_and_affine()[source]

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_transforms()[source]
get_url()[source]

Return the url.

get_urls()[source]

Return a list of URLs, one for each element of the collection.

The list contains None for elements without a URL. See Hyperlinks for an example.

get_visible()[source]

Return the visibility.

get_window_extent(renderer)[source]

Get the artist's bounding box in display space.

The bounding box' width and height are nonnegative.

Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

get_zorder()[source]

Return the artist's zorder.

have_units()[source]

Return whether units are set on any axis.

is_transform_set()[source]

Return whether the Artist has an explicitly set transform.

This is True after set_transform has been called.

propertymouseover

If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.

See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.

propertynorm
pchanged()[source]

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

pickable()[source]

Return whether the artist is pickable.

properties()[source]

Return a dictionary of all the properties of the artist.

remove()[source]

Remove the artist from the figure if possible.

The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

Note: relim will not see collections even if the collection was added to the axes with autolim = True.

Note: there is no support for removing the artist's legend entry.

remove_callback(oid)[source]

Remove a callback based on its observer id.

See also

add_callback
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array

alpha

array-like or scalar or None

animated

bool

antialiased or aa or antialiaseds

bool or list of bools

array

array-like or None

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

Bbox

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of rgba tuples

edgecolor or ec or edgecolors

color or list of colors or 'face'

facecolor or facecolors or fc

color or list of colors

figure

Figure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linestyle or dashes or linestyles or ls

str or tuple or list thereof

linewidth or linewidths or lw

float or list of floats

norm

Normalize or None

offset_transform

Transform

offsets

(N, 2) or (2,) array-like

path_effects

AbstractPathEffect

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

visible

bool

zorder

float

set_aa(aa)[source]

Alias for set_antialiased.

set_agg_filter(filter_func)[source]

Set the agg filter.

Parameters
filter_funccallable

A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

set_alpha(alpha)[source]

Set the alpha value used for blending - not supported on all backends.

Parameters
alphaarray-like or scalar or None

All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)[source]

Set whether the artist is intended to be used in an animation.

If True, the artist is excluded from regular drawing of the figure. You have to call Figure.draw_artist / Axes.draw_artist explicitly on the artist. This appoach is used to speed up animations using blitting.

See also matplotlib.animation and Faster rendering by using blitting.

Parameters
bbool
set_antialiased(aa)[source]

Set the antialiasing state for rendering.

Parameters
aabool or list of bools
set_antialiaseds(aa)[source]

Alias for set_antialiased.

set_array(A)[source]

Set the value array from array-like A.

Parameters
Aarray-like or None

The values that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.

set_capstyle(cs)[source]

Set the CapStyle for the collection (for all its elements).

Parameters
csCapStyle or {'butt', 'projecting', 'round'}
set_clim(vmin=None, vmax=None)[source]

Set the norm limits for image scaling.

Parameters
vmin, vmaxfloat

The limits.

The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.

set_clip_box(clipbox)[source]

Set the artist's clip Bbox.

Parameters
clipboxBbox
set_clip_on(b)[source]

Set whether the artist uses clipping.

When False artists will be visible outside of the axes which can lead to unexpected results.

Parameters
bbool
set_clip_path(path, transform=None)[source]

Set the artist's clip path.

Parameters
pathPatch or Path or TransformedPath or None

The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed.

transformTransform, optional

Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform.

Notes

For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter.

set_cmap(cmap)[source]

Set the colormap for luminance data.

Parameters
cmapColormap or str or None
set_color(c)[source]

Set both the edgecolor and the facecolor.

Parameters
ccolor or list of rgba tuples

See also

Collection.set_facecolor, Collection.set_edgecolor

For setting the edge or face color individually.

set_dashes(ls)[source]

Alias for set_linestyle.

set_ec(c)[source]

Alias for set_edgecolor.

set_edgecolor(c)[source]

Set the edgecolor(s) of the collection.

Parameters
ccolor or list of colors or 'face'

The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.

set_edgecolors(c)[source]

Alias for set_edgecolor.

set_facecolor(c)[source]

Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.

If c is 'none', the patch will not be filled.

Parameters
ccolor or list of colors
set_facecolors(c)[source]

Alias for set_facecolor.

set_fc(c)[source]

Alias for set_facecolor.

set_figure(fig)[source]

Set the Figure instance the artist belongs to.

Parameters
figFigure
set_gid(gid)[source]

Set the (group) id for the artist.

Parameters
gidstr
set_hatch(hatch)[source]

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.

Parameters
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_in_layout(in_layout)[source]

Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

Parameters
in_layoutbool
set_joinstyle(js)[source]

Set the JoinStyle for the collection (for all its elements).

Parameters
jsJoinStyle or {'miter', 'round', 'bevel'}
set_label(s)[source]

Set a label that will be displayed in the legend.

Parameters
sobject

s will be converted to a string by calling str.

set_linestyle(ls)[source]

Set the linestyle(s) for the collection.

linestyle

description

'-' or 'solid'

solid line

'--' or 'dashed'

dashed line

'-.' or 'dashdot'

dash-dotted line

':' or 'dotted'

dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

Parameters
lsstr or tuple or list thereof

Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle for a complete description.

set_linestyles(ls)[source]

Alias for set_linestyle.

set_linewidth(lw)[source]

Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence

Parameters
lwfloat or list of floats
set_linewidths(lw)[source]

Alias for set_linewidth.

set_ls(ls)[source]

Alias for set_linestyle.

set_lw(lw)[source]

Alias for set_linewidth.

set_norm(norm)[source]

Set the normalization instance.

Parameters
normNormalize or None

Notes

If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.

set_offset_transform(transOffset)[source]

Set the artist offset transform.

Parameters
transOffsetTransform
set_offsets(offsets)[source]

Set the offsets for the collection.

Parameters
offsets(N, 2) or (2,) array-like
set_path_effects(path_effects)[source]

Set the path effects.

Parameters
path_effectsAbstractPathEffect
set_paths()[source]
set_picker(picker)[source]

Define the picking behavior of the artist.

Parameters
pickerNone or bool or float or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).
  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
  • A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

set_pickradius(pr)[source]

Set the pick radius used for containment tests.

Parameters
prfloat

Pick radius, in points.

set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output.

Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.

This setting is ignored for pixel-based output.

See also Rasterization for vector graphics.

Parameters
rasterizedbool
set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.

Parameters
scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.

lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)

randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.

set_snap(snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
set_transform(t)[source]

Set the artist transform.

Parameters
tTransform
set_url(url)[source]

Set the url for the artist.

Parameters
urlstr
set_urls(urls)[source]
Parameters
urlslist of str or None

Notes

URLs are currently only implemented by the SVG backend. They are ignored by all other backends.

set_visible(b)[source]

Set the artist's visibility.

Parameters
bbool
set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.

Parameters
levelfloat
propertystale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

propertysticky_edges

x and y sticky edge lists for autoscaling.

When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.

Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.

This attribute cannot be assigned to; however, the x and y lists can be modified in place as needed.

Examples

>>> artist.sticky_edges.x[:] = (xmin, xmax)
>>> artist.sticky_edges.y[:] = (ymin, ymax)
to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x.

In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.

There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.

If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).

update(props)[source]

Update this artist's properties from the dict props.

Parameters
propsdict
update_from(other)[source]

Copy properties from other to self.

update_scalarmappable()[source]

Update colors from the scalar mappable array, if any.

Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.

zorder=0
classmatplotlib.collections.EventCollection(positions, orientation='horizontal', lineoffset=0, linelength=1, linewidth=None, color=None, linestyle='solid', antialiased=None, **kwargs)[source]

Bases: matplotlib.collections.LineCollection

A collection of locations along a single axis at which an "event" occurred.

The events are given by a 1-dimensional array. They do not have an amplitude and are displayed as parallel lines.

Parameters
positions1D array-like

Each value is an event.

orientation{'horizontal', 'vertical'}, default: 'horizontal'

The sequence of events is plotted along this direction. The marker lines of the single events are along the orthogonal direction.

lineoffsetfloat, default: 0

The offset of the center of the markers from the origin, in the direction orthogonal to orientation.

linelengthfloat, default: 1

The total height of the marker (i.e. the marker stretches from lineoffset - linelength/2 to lineoffset + linelength/2).

linewidthfloat or list thereof, default: rcParams["lines.linewidth"] (default: 1.5)

The line width of the event lines, in points.

colorcolor or list of colors, default: rcParams["lines.color"] (default: 'C0')

The color of the event lines.

linestylestr or tuple or list thereof, default: 'solid'

Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

antialiasedbool or list thereof, default: rcParams["lines.antialiased"] (default: True)

Whether to use antialiasing for drawing the lines.

**kwargs

Forwarded to LineCollection.

Examples

(Source code, png, pdf)

../_images/eventcollection_demo.png
add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters
funccallable

The callback function. It must have the signature:

def func(artist: Artist) -> Any

where artist is the calling Artist. Return values may exist but are ignored.

Returns
int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.

See also

remove_callback
add_positions(position)[source]

Add one or more events at the specified positions.

append_positions(position)[source]

Add one or more events at the specified positions.

autoscale()[source]

Autoscale the scalar limits on the norm instance using the current array

autoscale_None()[source]

Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None

propertyaxes

The Axes instance the artist resides in, or None.

propertycallbacksSM[source]
changed()[source]

Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.

colorbar

The last colorbar associated with this ScalarMappable. May be None.

contains(mouseevent)[source]

Test whether the mouse event occurred in the collection.

Returns bool, dict(ind=itemlist), where every item in itemlist contains the event.

convert_xunits(x)[source]

Convert x using the unit type of the xaxis.

If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.

convert_yunits(y)[source]

Convert y using the unit type of the yaxis.

If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

extend_positions(position)[source]

Add one or more events at the specified positions.

findobj(match=None, include_self=True)[source]

Find artist objects.

Recursively find all Artist instances contained in the artist.

Parameters
match

A filter criterion for the matches. This can be

  • None: Return all objects contained in artist.
  • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.
  • A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.

Returns
list of Artist
format_cursor_data(data)[source]

Return a string representation of data.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.

See also

get_cursor_data
get_agg_filter()[source]

Return filter function to be used for agg filter.

get_alpha()[source]

Return the alpha value used for blending - not supported on all backends.

get_animated()[source]

Return whether the artist is animated.

get_array()[source]

Return the array of values, that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.

get_capstyle()[source]
get_children()[source]

Return a list of the child Artists of this Artist.

get_clim()[source]

Return the values (min, max) that are mapped to the colormap limits.

get_clip_box()[source]

Return the clipbox.

get_clip_on()[source]

Return whether the artist uses clipping.

get_clip_path()[source]

Return the clip path.

get_cmap()[source]

Return the Colormap instance.

get_color()[source]

Return the color of the lines used to mark each event.

get_colors()[source]
get_cursor_data(event)[source]

Return the cursor data for a given event.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.

Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.

The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.

Parameters
eventmatplotlib.backend_bases.MouseEvent
get_dashes()[source]

Alias for get_linestyle.

get_datalim(transData)[source]
get_ec()[source]

Alias for get_edgecolor.

get_edgecolor()[source]
get_edgecolors()[source]

Alias for get_edgecolor.

get_facecolor()[source]
get_facecolors()[source]

Alias for get_facecolor.

get_fc()[source]

Alias for get_facecolor.

get_figure()[source]

Return the Figure instance the artist belongs to.

get_fill()[source]

Return whether face is colored.

get_gid()[source]

Return the group id.

get_hatch()[source]

Return the current hatching pattern.

get_in_layout()[source]

Return boolean flag, True if artist is included in layout calculations.

E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

get_joinstyle()[source]
get_label()[source]

Return the label used for this artist in the legend.

get_linelength()[source]

Return the length of the lines used to mark each event.

get_lineoffset()[source]

Return the offset of the lines used to mark each event.

get_linestyle()[source]
get_linestyles()[source]

Alias for get_linestyle.

get_linewidth()[source]

Get the width of the lines used to mark each event.

get_linewidths()[source]

Alias for get_linewidth.

get_ls()[source]

Alias for get_linestyle.

get_lw()[source]

Alias for get_linewidth.

get_offset_transform()[source]

Return the Transform instance used by this artist offset.

get_offsets()[source]

Return the offsets for the collection.

get_orientation()[source]

Return the orientation of the event line ('horizontal' or 'vertical').

get_path_effects()[source]
get_paths()[source]
get_picker()[source]

Return the picking behavior of the artist.

The possible values are described in set_picker.

See also

set_picker, pickable, pick
get_pickradius()[source]
get_positions()[source]

Return an array containing the floating-point values of the positions.

get_rasterized()[source]

Return whether the artist is to be rasterized.

get_segments()[source]
Returns
list

List of segments in the LineCollection. Each list item contains an array of vertices.

get_sketch_params()[source]

Return the sketch parameters for the artist.

Returns
tuple or None

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.
  • length: The length of the wiggle along the line.
  • randomness: The scale factor by which the length is shrunken or expanded.

Returns None if no sketch parameters were set.

get_snap()[source]

Return the snap setting.

See set_snap for details.

get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.

Parameters
rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

Returns
Bbox

The enclosing bounding box (in figure pixel coordinates).

get_transform()[source]

Return the Transform instance used by this artist.

get_transformed_clip_path_and_affine()[source]

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_transforms()[source]
get_url()[source]

Return the url.

get_urls()[source]

Return a list of URLs, one for each element of the collection.

The list contains None for elements without a URL. See Hyperlinks for an example.

get_visible()[source]

Return the visibility.

get_window_extent(renderer)[source]

Get the artist's bounding box in display space.

The bounding box' width and height are nonnegative.

Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

get_zorder()[source]

Return the artist's zorder.

have_units()[source]

Return whether units are set on any axis.

is_horizontal()[source]

True if the eventcollection is horizontal, False if vertical.

is_transform_set()[source]

Return whether the Artist has an explicitly set transform.

This is True after set_transform has been called.

propertymouseover

If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.

See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.

propertynorm
pchanged()[source]

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

pickable()[source]

Return whether the artist is pickable.

properties()[source]

Return a dictionary of all the properties of the artist.

remove()[source]

Remove the artist from the figure if possible.

The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

Note: relim will not see collections even if the collection was added to the axes with autolim = True.

Note: there is no support for removing the artist's legend entry.

remove_callback(oid)[source]

Remove a callback based on its observer id.

See also

add_callback
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, colors=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linelength=<UNSET>, lineoffset=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, orientation=<UNSET>, path_effects=<UNSET>, paths=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, positions=<UNSET>, rasterized=<UNSET>, segments=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, verts=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array

alpha

array-like or scalar or None

animated

bool

antialiased or aa or antialiaseds

bool or list of bools

array

array-like or None

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

Bbox

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of colors

colors

color or list of colors

edgecolor or ec or edgecolors

color or list of colors or 'face'

facecolor or facecolors or fc

color or list of colors

figure

Figure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linelength

unknown

lineoffset

unknown

linestyle or dashes or linestyles or ls

str or tuple or list thereof

linewidth or linewidths or lw

float or list of floats

norm

Normalize or None

offset_transform

Transform

offsets

(N, 2) or (2,) array-like

orientation

{'horizontal', 'vertical'}

path_effects

AbstractPathEffect

paths

unknown

picker

None or bool or float or callable

pickradius

float

positions

unknown

rasterized

bool

segments

unknown

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

verts

unknown

visible

bool

zorder

float

set_aa(aa)[source]

Alias for set_antialiased.

set_agg_filter(filter_func)[source]

Set the agg filter.

Parameters
filter_funccallable

A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

set_alpha(alpha)[source]

Set the alpha value used for blending - not supported on all backends.

Parameters
alphaarray-like or scalar or None

All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)[source]

Set whether the artist is intended to be used in an animation.

If True, the artist is excluded from regular drawing of the figure. You have to call Figure.draw_artist / Axes.draw_artist explicitly on the artist. This appoach is used to speed up animations using blitting.

See also matplotlib.animation and Faster rendering by using blitting.

Parameters
bbool
set_antialiased(aa)[source]

Set the antialiasing state for rendering.

Parameters
aabool or list of bools
set_antialiaseds(aa)[source]

Alias for set_antialiased.

set_array(A)[source]

Set the value array from array-like A.

Parameters
Aarray-like or None

The values that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.

set_capstyle(cs)[source]

Set the CapStyle for the collection (for all its elements).

Parameters
csCapStyle or {'butt', 'projecting', 'round'}
set_clim(vmin=None, vmax=None)[source]

Set the norm limits for image scaling.

Parameters
vmin, vmaxfloat

The limits.

The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.

set_clip_box(clipbox)[source]

Set the artist's clip Bbox.

Parameters
clipboxBbox
set_clip_on(b)[source]

Set whether the artist uses clipping.

When False artists will be visible outside of the axes which can lead to unexpected results.

Parameters
bbool
set_clip_path(path, transform=None)[source]

Set the artist's clip path.

Parameters
pathPatch or Path or TransformedPath or None

The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed.

transformTransform, optional

Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform.

Notes

For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter.

set_cmap(cmap)[source]

Set the colormap for luminance data.

Parameters
cmapColormap or str or None
set_color(c)[source]

Set the edgecolor(s) of the LineCollection.

Parameters
ccolor or list of colors

Single color (all lines have same color), or a sequence of rgba tuples; if it is a sequence the lines will cycle through the sequence.

set_colors(c)[source]

Set the edgecolor(s) of the LineCollection.

Parameters
ccolor or list of colors

Single color (all lines have same color), or a sequence of rgba tuples; if it is a sequence the lines will cycle through the sequence.

set_dashes(ls)[source]

Alias for set_linestyle.

set_ec(c)[source]

Alias for set_edgecolor.

set_edgecolor(c)[source]

Set the edgecolor(s) of the collection.

Parameters
ccolor or list of colors or 'face'

The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.

set_edgecolors(c)[source]

Alias for set_edgecolor.

set_facecolor(c)[source]

Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.

If c is 'none', the patch will not be filled.

Parameters
ccolor or list of colors
set_facecolors(c)[source]

Alias for set_facecolor.

set_fc(c)[source]

Alias for set_facecolor.

set_figure(fig)[source]

Set the Figure instance the artist belongs to.

Parameters
figFigure
set_gid(gid)[source]

Set the (group) id for the artist.

Parameters
gidstr
set_hatch(hatch)[source]

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.

Parameters
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_in_layout(in_layout)[source]

Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

Parameters
in_layoutbool
set_joinstyle(js)[source]

Set the JoinStyle for the collection (for all its elements).

Parameters
jsJoinStyle or {'miter', 'round', 'bevel'}
set_label(s)[source]

Set a label that will be displayed in the legend.

Parameters
sobject

s will be converted to a string by calling str.

set_linelength(linelength)[source]

Set the length of the lines used to mark each event.

set_lineoffset(lineoffset)[source]

Set the offset of the lines used to mark each event.

set_linestyle(ls)[source]

Set the linestyle(s) for the collection.

linestyle

description

'-' or 'solid'

solid line

'--' or 'dashed'

dashed line

'-.' or 'dashdot'

dash-dotted line

':' or 'dotted'

dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

Parameters
lsstr or tuple or list thereof

Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle for a complete description.

set_linestyles(ls)[source]

Alias for set_linestyle.

set_linewidth(lw)[source]

Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence

Parameters
lwfloat or list of floats
set_linewidths(lw)[source]

Alias for set_linewidth.

set_ls(ls)[source]

Alias for set_linestyle.

set_lw(lw)[source]

Alias for set_linewidth.

set_norm(norm)[source]

Set the normalization instance.

Parameters
normNormalize or None

Notes

If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.

set_offset_transform(transOffset)[source]

Set the artist offset transform.

Parameters
transOffsetTransform
set_offsets(offsets)[source]

Set the offsets for the collection.

Parameters
offsets(N, 2) or (2,) array-like
set_orientation(orientation)[source]

Set the orientation of the event line.

Parameters
orientation{'horizontal', 'vertical'}
set_path_effects(path_effects)[source]

Set the path effects.

Parameters
path_effectsAbstractPathEffect
set_paths(segments)[source]
set_picker(picker)[source]

Define the picking behavior of the artist.

Parameters
pickerNone or bool or float or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).
  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
  • A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

set_pickradius(pr)[source]

Set the pick radius used for containment tests.

Parameters
prfloat

Pick radius, in points.

set_positions(positions)[source]

Set the positions of the events.

set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output.

Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.

This setting is ignored for pixel-based output.

See also Rasterization for vector graphics.

Parameters
rasterizedbool
set_segments(segments)[source]
set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.

Parameters
scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.

lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)

randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.

set_snap(snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
set_transform(t)[source]

Set the artist transform.

Parameters
tTransform
set_url(url)[source]

Set the url for the artist.

Parameters
urlstr
set_urls(urls)[source]
Parameters
urlslist of str or None

Notes

URLs are currently only implemented by the SVG backend. They are ignored by all other backends.

set_verts(segments)[source]
set_visible(b)[source]

Set the artist's visibility.

Parameters
bbool
set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.

Parameters
levelfloat
propertystale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

propertysticky_edges

x and y sticky edge lists for autoscaling.

When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.

Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.

This attribute cannot be assigned to; however, the x and y lists can be modified in place as needed.

Examples

>>> artist.sticky_edges.x[:] = (xmin, xmax)
>>> artist.sticky_edges.y[:] = (ymin, ymax)
switch_orientation()[source]

Switch the orientation of the event line, either from vertical to horizontal or vice versus.

to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x.

In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.

There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.

If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).

update(props)[source]

Update this artist's properties from the dict props.

Parameters
propsdict
update_from(other)[source]

Copy properties from other to self.

update_scalarmappable()[source]

Update colors from the scalar mappable array, if any.

Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.

zorder=0
classmatplotlib.collections.LineCollection(segments, *args, zorder=2, **kwargs)[source]

Bases: matplotlib.collections.Collection

Represents a sequence of Line2Ds that should be drawn together.

This class extends Collection to represent a sequence of Line2Ds instead of just a sequence of Patchs. Just as in Collection, each property of a LineCollection may be either a single value or a list of values. This list is then used cyclically for each element of the LineCollection, so the property of the ith element of the collection is:

prop[i % len(prop)]

The properties of each member of a LineCollection default to their values in rcParams["lines.*"] instead of rcParams["patch.*"], and the property colors is added in place of edgecolors.

Parameters
segmentslist of array-like

A sequence of (line0, line1, line2), where:

linen = (x0, y0), (x1, y1), ... (xm, ym)

or the equivalent numpy array with two columns. Each line can have a different number of segments.

linewidthsfloat or list of float, default: rcParams["lines.linewidth"] (default: 1.5)

The width of each line in points.

colorscolor or list of color, default: rcParams["lines.color"] (default: 'C0')

A sequence of RGBA tuples (e.g., arbitrary color strings, etc, not allowed).

antialiasedsbool or list of bool, default: rcParams["lines.antialiased"] (default: True)

Whether to use antialiasing for each line.

zorderint, default: 2

zorder of the lines once drawn.

facecolorscolor or list of color, default: 'none'

When setting facecolors, each line is interpreted as a boundary for an area, implicitly closing the path from the last point to the first point. The enclosed area is filled with facecolor. In order to manually specify what should count as the "interior" of each line, please use PathCollection instead, where the "interior" can be specified by appropriate usage of CLOSEPOLY.

**kwargs

Forwarded to Collection.

add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters
funccallable

The callback function. It must have the signature:

def func(artist: Artist) -> Any

where artist is the calling Artist. Return values may exist but are ignored.

Returns
int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.

See also

remove_callback
autoscale()[source]

Autoscale the scalar limits on the norm instance using the current array

autoscale_None()[source]

Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None

propertyaxes

The Axes instance the artist resides in, or None.

propertycallbacksSM[source]
changed()[source]

Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.

colorbar

The last colorbar associated with this ScalarMappable. May be None.

contains(mouseevent)[source]

Test whether the mouse event occurred in the collection.

Returns bool, dict(ind=itemlist), where every item in itemlist contains the event.

convert_xunits(x)[source]

Convert x using the unit type of the xaxis.

If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.

convert_yunits(y)[source]

Convert y using the unit type of the yaxis.

If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

findobj(match=None, include_self=True)[source]

Find artist objects.

Recursively find all Artist instances contained in the artist.

Parameters
match

A filter criterion for the matches. This can be

  • None: Return all objects contained in artist.
  • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.
  • A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.

Returns
list of Artist
format_cursor_data(data)[source]

Return a string representation of data.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.

See also

get_cursor_data
get_agg_filter()[source]

Return filter function to be used for agg filter.

get_alpha()[source]

Return the alpha value used for blending - not supported on all backends.

get_animated()[source]

Return whether the artist is animated.

get_array()[source]

Return the array of values, that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.

get_capstyle()[source]
get_children()[source]

Return a list of the child Artists of this Artist.

get_clim()[source]

Return the values (min, max) that are mapped to the colormap limits.

get_clip_box()[source]

Return the clipbox.

get_clip_on()[source]

Return whether the artist uses clipping.

get_clip_path()[source]

Return the clip path.

get_cmap()[source]

Return the Colormap instance.

get_color()[source]
get_colors()[source]
get_cursor_data(event)[source]

Return the cursor data for a given event.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.

Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.

The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.

Parameters
eventmatplotlib.backend_bases.MouseEvent
get_dashes()[source]

Alias for get_linestyle.

get_datalim(transData)[source]
get_ec()[source]

Alias for get_edgecolor.

get_edgecolor()[source]
get_edgecolors()[source]

Alias for get_edgecolor.

get_facecolor()[source]
get_facecolors()[source]

Alias for get_facecolor.

get_fc()[source]

Alias for get_facecolor.

get_figure()[source]

Return the Figure instance the artist belongs to.

get_fill()[source]

Return whether face is colored.

get_gid()[source]

Return the group id.

get_hatch()[source]

Return the current hatching pattern.

get_in_layout()[source]

Return boolean flag, True if artist is included in layout calculations.

E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

get_joinstyle()[source]
get_label()[source]

Return the label used for this artist in the legend.

get_linestyle()[source]
get_linestyles()[source]

Alias for get_linestyle.

get_linewidth()[source]
get_linewidths()[source]

Alias for get_linewidth.

get_ls()[source]

Alias for get_linestyle.

get_lw()[source]

Alias for get_linewidth.

get_offset_transform()[source]

Return the Transform instance used by this artist offset.

get_offsets()[source]

Return the offsets for the collection.

get_path_effects()[source]
get_paths()[source]
get_picker()[source]

Return the picking behavior of the artist.

The possible values are described in set_picker.

See also

set_picker, pickable, pick
get_pickradius()[source]
get_rasterized()[source]

Return whether the artist is to be rasterized.

get_segments()[source]
Returns
list

List of segments in the LineCollection. Each list item contains an array of vertices.

get_sketch_params()[source]

Return the sketch parameters for the artist.

Returns
tuple or None

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.
  • length: The length of the wiggle along the line.
  • randomness: The scale factor by which the length is shrunken or expanded.

Returns None if no sketch parameters were set.

get_snap()[source]

Return the snap setting.

See set_snap for details.

get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.

Parameters
rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

Returns
Bbox

The enclosing bounding box (in figure pixel coordinates).

get_transform()[source]

Return the Transform instance used by this artist.

get_transformed_clip_path_and_affine()[source]

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_transforms()[source]
get_url()[source]

Return the url.

get_urls()[source]

Return a list of URLs, one for each element of the collection.

The list contains None for elements without a URL. See Hyperlinks for an example.

get_visible()[source]

Return the visibility.

get_window_extent(renderer)[source]

Get the artist's bounding box in display space.

The bounding box' width and height are nonnegative.

Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

get_zorder()[source]

Return the artist's zorder.

have_units()[source]

Return whether units are set on any axis.

is_transform_set()[source]

Return whether the Artist has an explicitly set transform.

This is True after set_transform has been called.

propertymouseover

If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.

See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.

propertynorm
pchanged()[source]

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

pickable()[source]

Return whether the artist is pickable.

properties()[source]

Return a dictionary of all the properties of the artist.

remove()[source]

Remove the artist from the figure if possible.

The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

Note: relim will not see collections even if the collection was added to the axes with autolim = True.

Note: there is no support for removing the artist's legend entry.

remove_callback(oid)[source]

Remove a callback based on its observer id.

See also

add_callback
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, colors=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, paths=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, segments=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, verts=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array

alpha

array-like or scalar or None

animated

bool

antialiased or aa or antialiaseds

bool or list of bools

array

array-like or None

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

Bbox

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of colors

colors

color or list of colors

edgecolor or ec or edgecolors

color or list of colors or 'face'

facecolor or facecolors or fc

color or list of colors

figure

Figure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linestyle or dashes or linestyles or ls

str or tuple or list thereof

linewidth or linewidths or lw

float or list of floats

norm

Normalize or None

offset_transform

Transform

offsets

(N, 2) or (2,) array-like

path_effects

AbstractPathEffect

paths

unknown

picker

None or bool or float or callable

pickradius

float

rasterized

bool

segments

unknown

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

verts

unknown

visible

bool

zorder

float

set_aa(aa)[source]

Alias for set_antialiased.

set_agg_filter(filter_func)[source]

Set the agg filter.

Parameters
filter_funccallable

A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

set_alpha(alpha)[source]

Set the alpha value used for blending - not supported on all backends.

Parameters
alphaarray-like or scalar or None

All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)[source]

Set whether the artist is intended to be used in an animation.

If True, the artist is excluded from regular drawing of the figure. You have to call Figure.draw_artist / Axes.draw_artist explicitly on the artist. This appoach is used to speed up animations using blitting.

See also matplotlib.animation and Faster rendering by using blitting.

Parameters
bbool
set_antialiased(aa)[source]

Set the antialiasing state for rendering.

Parameters
aabool or list of bools
set_antialiaseds(aa)[source]

Alias for set_antialiased.

set_array(A)[source]

Set the value array from array-like A.

Parameters
Aarray-like or None

The values that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.

set_capstyle(cs)[source]

Set the CapStyle for the collection (for all its elements).

Parameters
csCapStyle or {'butt', 'projecting', 'round'}
set_clim(vmin=None, vmax=None)[source]

Set the norm limits for image scaling.

Parameters
vmin, vmaxfloat

The limits.

The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.

set_clip_box(clipbox)[source]

Set the artist's clip Bbox.

Parameters
clipboxBbox
set_clip_on(b)[source]

Set whether the artist uses clipping.

When False artists will be visible outside of the axes which can lead to unexpected results.

Parameters
bbool
set_clip_path(path, transform=None)[source]

Set the artist's clip path.

Parameters
pathPatch or Path or TransformedPath or None

The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed.

transformTransform, optional

Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform.

Notes

For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter.

set_cmap(cmap)[source]

Set the colormap for luminance data.

Parameters
cmapColormap or str or None
set_color(c)[source]

Set the edgecolor(s) of the LineCollection.

Parameters
ccolor or list of colors

Single color (all lines have same color), or a sequence of rgba tuples; if it is a sequence the lines will cycle through the sequence.

set_colors(c)[source]

Set the edgecolor(s) of the LineCollection.

Parameters
ccolor or list of colors

Single color (all lines have same color), or a sequence of rgba tuples; if it is a sequence the lines will cycle through the sequence.

set_dashes(ls)[source]

Alias for set_linestyle.

set_ec(c)[source]

Alias for set_edgecolor.

set_edgecolor(c)[source]

Set the edgecolor(s) of the collection.

Parameters
ccolor or list of colors or 'face'

The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.

set_edgecolors(c)[source]

Alias for set_edgecolor.

set_facecolor(c)[source]

Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.

If c is 'none', the patch will not be filled.

Parameters
ccolor or list of colors
set_facecolors(c)[source]

Alias for set_facecolor.

set_fc(c)[source]

Alias for set_facecolor.

set_figure(fig)[source]

Set the Figure instance the artist belongs to.

Parameters
figFigure
set_gid(gid)[source]

Set the (group) id for the artist.

Parameters
gidstr
set_hatch(hatch)[source]

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.

Parameters
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_in_layout(in_layout)[source]

Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

Parameters
in_layoutbool
set_joinstyle(js)[source]

Set the JoinStyle for the collection (for all its elements).

Parameters
jsJoinStyle or {'miter', 'round', 'bevel'}
set_label(s)[source]

Set a label that will be displayed in the legend.

Parameters
sobject

s will be converted to a string by calling str.

set_linestyle(ls)[source]

Set the linestyle(s) for the collection.

linestyle

description

'-' or 'solid'

solid line

'--' or 'dashed'

dashed line

'-.' or 'dashdot'

dash-dotted line

':' or 'dotted'

dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

Parameters
lsstr or tuple or list thereof

Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle for a complete description.

set_linestyles(ls)[source]

Alias for set_linestyle.

set_linewidth(lw)[source]

Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence

Parameters
lwfloat or list of floats
set_linewidths(lw)[source]

Alias for set_linewidth.

set_ls(ls)[source]

Alias for set_linestyle.

set_lw(lw)[source]

Alias for set_linewidth.

set_norm(norm)[source]

Set the normalization instance.

Parameters
normNormalize or None

Notes

If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.

set_offset_transform(transOffset)[source]

Set the artist offset transform.

Parameters
transOffsetTransform
set_offsets(offsets)[source]

Set the offsets for the collection.

Parameters
offsets(N, 2) or (2,) array-like
set_path_effects(path_effects)[source]

Set the path effects.

Parameters
path_effectsAbstractPathEffect
set_paths(segments)[source]
set_picker(picker)[source]

Define the picking behavior of the artist.

Parameters
pickerNone or bool or float or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).
  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
  • A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

set_pickradius(pr)[source]

Set the pick radius used for containment tests.

Parameters
prfloat

Pick radius, in points.

set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output.

Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.

This setting is ignored for pixel-based output.

See also Rasterization for vector graphics.

Parameters
rasterizedbool
set_segments(segments)[source]
set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.

Parameters
scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.

lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)

randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.

set_snap(snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
set_transform(t)[source]

Set the artist transform.

Parameters
tTransform
set_url(url)[source]

Set the url for the artist.

Parameters
urlstr
set_urls(urls)[source]
Parameters
urlslist of str or None

Notes

URLs are currently only implemented by the SVG backend. They are ignored by all other backends.

set_verts(segments)[source]
set_visible(b)[source]

Set the artist's visibility.

Parameters
bbool
set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.

Parameters
levelfloat
propertystale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

propertysticky_edges

x and y sticky edge lists for autoscaling.

When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.

Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.

This attribute cannot be assigned to; however, the x and y lists can be modified in place as needed.

Examples

>>> artist.sticky_edges.x[:] = (xmin, xmax)
>>> artist.sticky_edges.y[:] = (ymin, ymax)
to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x.

In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.

There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.

If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).

update(props)[source]

Update this artist's properties from the dict props.

Parameters
propsdict
update_from(other)[source]

Copy properties from other to self.

update_scalarmappable()[source]

Update colors from the scalar mappable array, if any.

Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.

zorder=0
classmatplotlib.collections.PatchCollection(patches, match_original=False, **kwargs)[source]

Bases: matplotlib.collections.Collection

A generic collection of patches.

This makes it easier to assign a colormap to a heterogeneous collection of patches.

This also may improve plotting speed, since PatchCollection will draw faster than a large number of patches.

patches

a sequence of Patch objects. This list may include a heterogeneous assortment of different patch types.

match_original

If True, use the colors and linewidths of the original patches. If False, new colors may be assigned by providing the standard collection arguments, facecolor, edgecolor, linewidths, norm or cmap.

If any of edgecolors, facecolors, linewidths, antialiaseds are None, they default to their rcParams patch setting, in sequence form.

The use of ScalarMappable functionality is optional. If the ScalarMappable matrix _A has been set (via a call to set_array), at draw time a call to scalar mappable will be made to set the face colors.

add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters
funccallable

The callback function. It must have the signature:

def func(artist: Artist) -> Any

where artist is the calling Artist. Return values may exist but are ignored.

Returns
int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.

See also

remove_callback
autoscale()[source]

Autoscale the scalar limits on the norm instance using the current array

autoscale_None()[source]

Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None

propertyaxes

The Axes instance the artist resides in, or None.

propertycallbacksSM[source]
changed()[source]

Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.

colorbar

The last colorbar associated with this ScalarMappable. May be None.

contains(mouseevent)[source]

Test whether the mouse event occurred in the collection.

Returns bool, dict(ind=itemlist), where every item in itemlist contains the event.

convert_xunits(x)[source]

Convert x using the unit type of the xaxis.

If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.

convert_yunits(y)[source]

Convert y using the unit type of the yaxis.

If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

findobj(match=None, include_self=True)[source]

Find artist objects.

Recursively find all Artist instances contained in the artist.

Parameters
match

A filter criterion for the matches. This can be

  • None: Return all objects contained in artist.
  • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.
  • A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.

Returns
list of Artist
format_cursor_data(data)[source]

Return a string representation of data.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.

See also

get_cursor_data
get_agg_filter()[source]

Return filter function to be used for agg filter.

get_alpha()[source]

Return the alpha value used for blending - not supported on all backends.

get_animated()[source]

Return whether the artist is animated.

get_array()[source]

Return the array of values, that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.

get_capstyle()[source]
get_children()[source]

Return a list of the child Artists of this Artist.

get_clim()[source]

Return the values (min, max) that are mapped to the colormap limits.

get_clip_box()[source]

Return the clipbox.

get_clip_on()[source]

Return whether the artist uses clipping.

get_clip_path()[source]

Return the clip path.

get_cmap()[source]

Return the Colormap instance.

get_cursor_data(event)[source]

Return the cursor data for a given event.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.

Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.

The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.

Parameters
eventmatplotlib.backend_bases.MouseEvent
get_dashes()[source]

Alias for get_linestyle.

get_datalim(transData)[source]
get_ec()[source]

Alias for get_edgecolor.

get_edgecolor()[source]
get_edgecolors()[source]

Alias for get_edgecolor.

get_facecolor()[source]
get_facecolors()[source]

Alias for get_facecolor.

get_fc()[source]

Alias for get_facecolor.

get_figure()[source]

Return the Figure instance the artist belongs to.

get_fill()[source]

Return whether face is colored.

get_gid()[source]

Return the group id.

get_hatch()[source]

Return the current hatching pattern.

get_in_layout()[source]

Return boolean flag, True if artist is included in layout calculations.

E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

get_joinstyle()[source]
get_label()[source]

Return the label used for this artist in the legend.

get_linestyle()[source]
get_linestyles()[source]

Alias for get_linestyle.

get_linewidth()[source]
get_linewidths()[source]

Alias for get_linewidth.

get_ls()[source]

Alias for get_linestyle.

get_lw()[source]

Alias for get_linewidth.

get_offset_transform()[source]

Return the Transform instance used by this artist offset.

get_offsets()[source]

Return the offsets for the collection.

get_path_effects()[source]
get_paths()[source]
get_picker()[source]

Return the picking behavior of the artist.

The possible values are described in set_picker.

See also

set_picker, pickable, pick
get_pickradius()[source]
get_rasterized()[source]

Return whether the artist is to be rasterized.

get_sketch_params()[source]

Return the sketch parameters for the artist.

Returns
tuple or None

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.
  • length: The length of the wiggle along the line.
  • randomness: The scale factor by which the length is shrunken or expanded.

Returns None if no sketch parameters were set.

get_snap()[source]

Return the snap setting.

See set_snap for details.

get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.

Parameters
rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

Returns
Bbox

The enclosing bounding box (in figure pixel coordinates).

get_transform()[source]

Return the Transform instance used by this artist.

get_transformed_clip_path_and_affine()[source]

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_transforms()[source]
get_url()[source]

Return the url.

get_urls()[source]

Return a list of URLs, one for each element of the collection.

The list contains None for elements without a URL. See Hyperlinks for an example.

get_visible()[source]

Return the visibility.

get_window_extent(renderer)[source]

Get the artist's bounding box in display space.

The bounding box' width and height are nonnegative.

Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

get_zorder()[source]

Return the artist's zorder.

have_units()[source]

Return whether units are set on any axis.

is_transform_set()[source]

Return whether the Artist has an explicitly set transform.

This is True after set_transform has been called.

propertymouseover

If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.

See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.

propertynorm
pchanged()[source]

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

pickable()[source]

Return whether the artist is pickable.

properties()[source]

Return a dictionary of all the properties of the artist.

remove()[source]

Remove the artist from the figure if possible.

The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

Note: relim will not see collections even if the collection was added to the axes with autolim = True.

Note: there is no support for removing the artist's legend entry.

remove_callback(oid)[source]

Remove a callback based on its observer id.

See also

add_callback
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, paths=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array

alpha

array-like or scalar or None

animated

bool

antialiased or aa or antialiaseds

bool or list of bools

array

array-like or None

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

Bbox

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of rgba tuples

edgecolor or ec or edgecolors

color or list of colors or 'face'

facecolor or facecolors or fc

color or list of colors

figure

Figure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linestyle or dashes or linestyles or ls

str or tuple or list thereof

linewidth or linewidths or lw

float or list of floats

norm

Normalize or None

offset_transform

Transform

offsets

(N, 2) or (2,) array-like

path_effects

AbstractPathEffect

paths

unknown

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

visible

bool

zorder

float

set_aa(aa)[source]

Alias for set_antialiased.

set_agg_filter(filter_func)[source]

Set the agg filter.

Parameters
filter_funccallable

A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

set_alpha(alpha)[source]

Set the alpha value used for blending - not supported on all backends.

Parameters
alphaarray-like or scalar or None

All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)[source]

Set whether the artist is intended to be used in an animation.

If True, the artist is excluded from regular drawing of the figure. You have to call Figure.draw_artist / Axes.draw_artist explicitly on the artist. This appoach is used to speed up animations using blitting.

See also matplotlib.animation and Faster rendering by using blitting.

Parameters
bbool
set_antialiased(aa)[source]

Set the antialiasing state for rendering.

Parameters
aabool or list of bools
set_antialiaseds(aa)[source]

Alias for set_antialiased.

set_array(A)[source]

Set the value array from array-like A.

Parameters
Aarray-like or None

The values that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.

set_capstyle(cs)[source]

Set the CapStyle for the collection (for all its elements).

Parameters
csCapStyle or {'butt', 'projecting', 'round'}
set_clim(vmin=None, vmax=None)[source]

Set the norm limits for image scaling.

Parameters
vmin, vmaxfloat

The limits.

The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.

set_clip_box(clipbox)[source]

Set the artist's clip Bbox.

Parameters
clipboxBbox
set_clip_on(b)[source]

Set whether the artist uses clipping.

When False artists will be visible outside of the axes which can lead to unexpected results.

Parameters
bbool
set_clip_path(path, transform=None)[source]

Set the artist's clip path.

Parameters
pathPatch or Path or TransformedPath or None

The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed.

transformTransform, optional

Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform.

Notes

For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter.

set_cmap(cmap)[source]

Set the colormap for luminance data.

Parameters
cmapColormap or str or None
set_color(c)[source]

Set both the edgecolor and the facecolor.

Parameters
ccolor or list of rgba tuples

See also

Collection.set_facecolor, Collection.set_edgecolor

For setting the edge or face color individually.

set_dashes(ls)[source]

Alias for set_linestyle.

set_ec(c)[source]

Alias for set_edgecolor.

set_edgecolor(c)[source]

Set the edgecolor(s) of the collection.

Parameters
ccolor or list of colors or 'face'

The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.

set_edgecolors(c)[source]

Alias for set_edgecolor.

set_facecolor(c)[source]

Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.

If c is 'none', the patch will not be filled.

Parameters
ccolor or list of colors
set_facecolors(c)[source]

Alias for set_facecolor.

set_fc(c)[source]

Alias for set_facecolor.

set_figure(fig)[source]

Set the Figure instance the artist belongs to.

Parameters
figFigure
set_gid(gid)[source]

Set the (group) id for the artist.

Parameters
gidstr
set_hatch(hatch)[source]

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.

Parameters
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_in_layout(in_layout)[source]

Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

Parameters
in_layoutbool
set_joinstyle(js)[source]

Set the JoinStyle for the collection (for all its elements).

Parameters
jsJoinStyle or {'miter', 'round', 'bevel'}
set_label(s)[source]

Set a label that will be displayed in the legend.

Parameters
sobject

s will be converted to a string by calling str.

set_linestyle(ls)[source]

Set the linestyle(s) for the collection.

linestyle

description

'-' or 'solid'

solid line

'--' or 'dashed'

dashed line

'-.' or 'dashdot'

dash-dotted line

':' or 'dotted'

dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

Parameters
lsstr or tuple or list thereof

Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle for a complete description.

set_linestyles(ls)[source]

Alias for set_linestyle.

set_linewidth(lw)[source]

Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence

Parameters
lwfloat or list of floats
set_linewidths(lw)[source]

Alias for set_linewidth.

set_ls(ls)[source]

Alias for set_linestyle.

set_lw(lw)[source]

Alias for set_linewidth.

set_norm(norm)[source]

Set the normalization instance.

Parameters
normNormalize or None

Notes

If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.

set_offset_transform(transOffset)[source]

Set the artist offset transform.

Parameters
transOffsetTransform
set_offsets(offsets)[source]

Set the offsets for the collection.

Parameters
offsets(N, 2) or (2,) array-like
set_path_effects(path_effects)[source]

Set the path effects.

Parameters
path_effectsAbstractPathEffect
set_paths(patches)[source]
set_picker(picker)[source]

Define the picking behavior of the artist.

Parameters
pickerNone or bool or float or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).
  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
  • A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

set_pickradius(pr)[source]

Set the pick radius used for containment tests.

Parameters
prfloat

Pick radius, in points.

set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output.

Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.

This setting is ignored for pixel-based output.

See also Rasterization for vector graphics.

Parameters
rasterizedbool
set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.

Parameters
scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.

lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)

randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.

set_snap(snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
set_transform(t)[source]

Set the artist transform.

Parameters
tTransform
set_url(url)[source]

Set the url for the artist.

Parameters
urlstr
set_urls(urls)[source]
Parameters
urlslist of str or None

Notes

URLs are currently only implemented by the SVG backend. They are ignored by all other backends.

set_visible(b)[source]

Set the artist's visibility.

Parameters
bbool
set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.

Parameters
levelfloat
propertystale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

propertysticky_edges

x and y sticky edge lists for autoscaling.

When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.

Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.

This attribute cannot be assigned to; however, the x and y lists can be modified in place as needed.

Examples

>>> artist.sticky_edges.x[:] = (xmin, xmax)
>>> artist.sticky_edges.y[:] = (ymin, ymax)
to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x.

In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.

There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.

If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).

update(props)[source]

Update this artist's properties from the dict props.

Parameters
propsdict
update_from(other)[source]

Copy properties from other to self.

update_scalarmappable()[source]

Update colors from the scalar mappable array, if any.

Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.

zorder=0
classmatplotlib.collections.PathCollection(paths, sizes=None, **kwargs)[source]

Bases: matplotlib.collections._CollectionWithSizes

A collection of Paths, as created by e.g. scatter.

Parameters
pathslist of path.Path

The paths that will make up the Collection.

sizesarray-like

The factor by which to scale each drawn Path. One unit squared in the Path's data space is scaled to be sizes**2 points when rendered.

**kwargs

Forwarded to Collection.

add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters
funccallable

The callback function. It must have the signature:

def func(artist: Artist) -> Any

where artist is the calling Artist. Return values may exist but are ignored.

Returns
int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.

See also

remove_callback
autoscale()[source]

Autoscale the scalar limits on the norm instance using the current array

autoscale_None()[source]

Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None

propertyaxes

The Axes instance the artist resides in, or None.

propertycallbacksSM[source]
changed()[source]

Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.

colorbar

The last colorbar associated with this ScalarMappable. May be None.

contains(mouseevent)[source]

Test whether the mouse event occurred in the collection.

Returns bool, dict(ind=itemlist), where every item in itemlist contains the event.

convert_xunits(x)[source]

Convert x using the unit type of the xaxis.

If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.

convert_yunits(y)[source]

Convert y using the unit type of the yaxis.

If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

findobj(match=None, include_self=True)[source]

Find artist objects.

Recursively find all Artist instances contained in the artist.

Parameters
match

A filter criterion for the matches. This can be

  • None: Return all objects contained in artist.
  • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.
  • A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.

Returns
list of Artist
format_cursor_data(data)[source]

Return a string representation of data.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.

See also

get_cursor_data
get_agg_filter()[source]

Return filter function to be used for agg filter.

get_alpha()[source]

Return the alpha value used for blending - not supported on all backends.

get_animated()[source]

Return whether the artist is animated.

get_array()[source]

Return the array of values, that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.

get_capstyle()[source]
get_children()[source]

Return a list of the child Artists of this Artist.

get_clim()[source]

Return the values (min, max) that are mapped to the colormap limits.

get_clip_box()[source]

Return the clipbox.

get_clip_on()[source]

Return whether the artist uses clipping.

get_clip_path()[source]

Return the clip path.

get_cmap()[source]

Return the Colormap instance.

get_cursor_data(event)[source]

Return the cursor data for a given event.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.

Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.

The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.

Parameters
eventmatplotlib.backend_bases.MouseEvent
get_dashes()[source]

Alias for get_linestyle.

get_datalim(transData)[source]
get_ec()[source]

Alias for get_edgecolor.

get_edgecolor()[source]
get_edgecolors()[source]

Alias for get_edgecolor.

get_facecolor()[source]
get_facecolors()[source]

Alias for get_facecolor.

get_fc()[source]

Alias for get_facecolor.

get_figure()[source]

Return the Figure instance the artist belongs to.

get_fill()[source]

Return whether face is colored.

get_gid()[source]

Return the group id.

get_hatch()[source]

Return the current hatching pattern.

get_in_layout()[source]

Return boolean flag, True if artist is included in layout calculations.

E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

get_joinstyle()[source]
get_label()[source]

Return the label used for this artist in the legend.

get_linestyle()[source]
get_linestyles()[source]

Alias for get_linestyle.

get_linewidth()[source]
get_linewidths()[source]

Alias for get_linewidth.

get_ls()[source]

Alias for get_linestyle.

get_lw()[source]

Alias for get_linewidth.

get_offset_transform()[source]

Return the Transform instance used by this artist offset.

get_offsets()[source]

Return the offsets for the collection.

get_path_effects()[source]
get_paths()[source]
get_picker()[source]

Return the picking behavior of the artist.

The possible values are described in set_picker.

See also

set_picker, pickable, pick
get_pickradius()[source]
get_rasterized()[source]

Return whether the artist is to be rasterized.

get_sizes()[source]

Return the sizes ('areas') of the elements in the collection.

Returns
array

The 'area' of each element.

get_sketch_params()[source]

Return the sketch parameters for the artist.

Returns
tuple or None

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.
  • length: The length of the wiggle along the line.
  • randomness: The scale factor by which the length is shrunken or expanded.

Returns None if no sketch parameters were set.

get_snap()[source]

Return the snap setting.

See set_snap for details.

get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.

Parameters
rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

Returns
Bbox

The enclosing bounding box (in figure pixel coordinates).

get_transform()[source]

Return the Transform instance used by this artist.

get_transformed_clip_path_and_affine()[source]

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_transforms()[source]
get_url()[source]

Return the url.

get_urls()[source]

Return a list of URLs, one for each element of the collection.

The list contains None for elements without a URL. See Hyperlinks for an example.

get_visible()[source]

Return the visibility.

get_window_extent(renderer)[source]

Get the artist's bounding box in display space.

The bounding box' width and height are nonnegative.

Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

get_zorder()[source]

Return the artist's zorder.

have_units()[source]

Return whether units are set on any axis.

is_transform_set()[source]

Return whether the Artist has an explicitly set transform.

This is True after set_transform has been called.

legend_elements(prop='colors', num='auto', fmt=None, func=<function PathCollection.<lambda>>, **kwargs)[source]

Create legend handles and labels for a PathCollection.

Each legend handle is a Line2D representing the Path that was drawn, and each label is a string what each Path represents.

This is useful for obtaining a legend for a scatter plot; e.g.:

scatter = plt.scatter([1, 2, 3],  [4, 5, 6],  c=[7, 2, 3])
plt.legend(*scatter.legend_elements())

creates three legend elements, one for each color with the numerical values passed to c as the labels.

Also see the Automated legend creation example.

Parameters
prop{"colors", "sizes"}, default: "colors"

If "colors", the legend handles will show the different colors of the collection. If "sizes", the legend will show the different sizes. To set both, use kwargs to directly edit the Line2D properties.

numint, None, "auto" (default), array-like, or Locator

Target number of elements to create. If None, use all unique elements of the mappable array. If an integer, target to use num elements in the normed range. If "auto", try to determine which option better suits the nature of the data. The number of created elements may slightly deviate from num due to a Locator being used to find useful locations. If a list or array, use exactly those elements for the legend. Finally, a Locator can be provided.

fmtstr, Formatter, or None (default)

The format or formatter to use for the labels. If a string must be a valid input for a StrMethodFormatter. If None (the default), use a ScalarFormatter.

funcfunction, default: lambda x: x

Function to calculate the labels. Often the size (or color) argument to scatter will have been pre-processed by the user using a function s = f(x) to make the markers visible; e.g. size = np.log10(x). Providing the inverse of this function here allows that pre-processing to be inverted, so that the legend labels have the correct values; e.g. func = lambda x: 10**x.

**kwargs

Allowed keyword arguments are color and size. E.g. it may be useful to set the color of the markers if prop="sizes" is used; similarly to set the size of the markers if prop="colors" is used. Any further parameters are passed onto the Line2D instance. This may be useful to e.g. specify a different markeredgecolor or alpha for the legend handles.

Returns
handleslist of Line2D

Visual representation of each element of the legend.

labelslist of str

The string labels for elements of the legend.

propertymouseover

If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.

See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.

propertynorm
pchanged()[source]

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

pickable()[source]

Return whether the artist is pickable.

properties()[source]

Return a dictionary of all the properties of the artist.

remove()[source]

Remove the artist from the figure if possible.

The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

Note: relim will not see collections even if the collection was added to the axes with autolim = True.

Note: there is no support for removing the artist's legend entry.

remove_callback(oid)[source]

Remove a callback based on its observer id.

See also

add_callback
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, paths=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sizes=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array

alpha

array-like or scalar or None

animated

bool

antialiased or aa or antialiaseds

bool or list of bools

array

array-like or None

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

Bbox

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of rgba tuples

edgecolor or ec or edgecolors

color or list of colors or 'face'

facecolor or facecolors or fc

color or list of colors

figure

Figure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linestyle or dashes or linestyles or ls

str or tuple or list thereof

linewidth or linewidths or lw

float or list of floats

norm

Normalize or None

offset_transform

Transform

offsets

(N, 2) or (2,) array-like

path_effects

AbstractPathEffect

paths

unknown

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

ndarray or None

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

visible

bool

zorder

float

set_aa(aa)[source]

Alias for set_antialiased.

set_agg_filter(filter_func)[source]

Set the agg filter.

Parameters
filter_funccallable

A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

set_alpha(alpha)[source]

Set the alpha value used for blending - not supported on all backends.

Parameters
alphaarray-like or scalar or None

All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)[source]

Set whether the artist is intended to be used in an animation.

If True, the artist is excluded from regular drawing of the figure. You have to call Figure.draw_artist / Axes.draw_artist explicitly on the artist. This appoach is used to speed up animations using blitting.

See also matplotlib.animation and Faster rendering by using blitting.

Parameters
bbool
set_antialiased(aa)[source]

Set the antialiasing state for rendering.

Parameters
aabool or list of bools
set_antialiaseds(aa)[source]

Alias for set_antialiased.

set_array(A)[source]

Set the value array from array-like A.

Parameters
Aarray-like or None

The values that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.

set_capstyle(cs)[source]

Set the CapStyle for the collection (for all its elements).

Parameters
csCapStyle or {'butt', 'projecting', 'round'}
set_clim(vmin=None, vmax=None)[source]

Set the norm limits for image scaling.

Parameters
vmin, vmaxfloat

The limits.

The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.

set_clip_box(clipbox)[source]

Set the artist's clip Bbox.

Parameters
clipboxBbox
set_clip_on(b)[source]

Set whether the artist uses clipping.

When False artists will be visible outside of the axes which can lead to unexpected results.

Parameters
bbool
set_clip_path(path, transform=None)[source]

Set the artist's clip path.

Parameters
pathPatch or Path or TransformedPath or None

The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed.

transformTransform, optional

Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform.

Notes

For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter.

set_cmap(cmap)[source]

Set the colormap for luminance data.

Parameters
cmapColormap or str or None
set_color(c)[source]

Set both the edgecolor and the facecolor.

Parameters
ccolor or list of rgba tuples

See also

Collection.set_facecolor, Collection.set_edgecolor

For setting the edge or face color individually.

set_dashes(ls)[source]

Alias for set_linestyle.

set_ec(c)[source]

Alias for set_edgecolor.

set_edgecolor(c)[source]

Set the edgecolor(s) of the collection.

Parameters
ccolor or list of colors or 'face'

The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.

set_edgecolors(c)[source]

Alias for set_edgecolor.

set_facecolor(c)[source]

Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.

If c is 'none', the patch will not be filled.

Parameters
ccolor or list of colors
set_facecolors(c)[source]

Alias for set_facecolor.

set_fc(c)[source]

Alias for set_facecolor.

set_figure(fig)[source]

Set the Figure instance the artist belongs to.

Parameters
figFigure
set_gid(gid)[source]

Set the (group) id for the artist.

Parameters
gidstr
set_hatch(hatch)[source]

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.

Parameters
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_in_layout(in_layout)[source]

Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

Parameters
in_layoutbool
set_joinstyle(js)[source]

Set the JoinStyle for the collection (for all its elements).

Parameters
jsJoinStyle or {'miter', 'round', 'bevel'}
set_label(s)[source]

Set a label that will be displayed in the legend.

Parameters
sobject

s will be converted to a string by calling str.

set_linestyle(ls)[source]

Set the linestyle(s) for the collection.

linestyle

description

'-' or 'solid'

solid line

'--' or 'dashed'

dashed line

'-.' or 'dashdot'

dash-dotted line

':' or 'dotted'

dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

Parameters
lsstr or tuple or list thereof

Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle for a complete description.

set_linestyles(ls)[source]

Alias for set_linestyle.

set_linewidth(lw)[source]

Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence

Parameters
lwfloat or list of floats
set_linewidths(lw)[source]

Alias for set_linewidth.

set_ls(ls)[source]

Alias for set_linestyle.

set_lw(lw)[source]

Alias for set_linewidth.

set_norm(norm)[source]

Set the normalization instance.

Parameters
normNormalize or None

Notes

If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.

set_offset_transform(transOffset)[source]

Set the artist offset transform.

Parameters
transOffsetTransform
set_offsets(offsets)[source]

Set the offsets for the collection.

Parameters
offsets(N, 2) or (2,) array-like
set_path_effects(path_effects)[source]

Set the path effects.

Parameters
path_effectsAbstractPathEffect
set_paths(paths)[source]
set_picker(picker)[source]

Define the picking behavior of the artist.

Parameters
pickerNone or bool or float or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).
  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
  • A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

set_pickradius(pr)[source]

Set the pick radius used for containment tests.

Parameters
prfloat

Pick radius, in points.

set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output.

Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.

This setting is ignored for pixel-based output.

See also Rasterization for vector graphics.

Parameters
rasterizedbool
set_sizes(sizes, dpi=72.0)[source]

Set the sizes of each member of the collection.

Parameters
sizesndarray or None

The size to set for each element of the collection. The value is the 'area' of the element.

dpifloat, default: 72

The dpi of the canvas.

set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.

Parameters
scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.

lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)

randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.

set_snap(snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
set_transform(t)[source]

Set the artist transform.

Parameters
tTransform
set_url(url)[source]

Set the url for the artist.

Parameters
urlstr
set_urls(urls)[source]
Parameters
urlslist of str or None

Notes

URLs are currently only implemented by the SVG backend. They are ignored by all other backends.

set_visible(b)[source]

Set the artist's visibility.

Parameters
bbool
set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.

Parameters
levelfloat
propertystale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

propertysticky_edges

x and y sticky edge lists for autoscaling.

When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.

Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.

This attribute cannot be assigned to; however, the x and y lists can be modified in place as needed.

Examples

>>> artist.sticky_edges.x[:] = (xmin, xmax)
>>> artist.sticky_edges.y[:] = (ymin, ymax)
to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x.

In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.

There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.

If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).

update(props)[source]

Update this artist's properties from the dict props.

Parameters
propsdict
update_from(other)[source]

Copy properties from other to self.

update_scalarmappable()[source]

Update colors from the scalar mappable array, if any.

Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.

zorder=0
classmatplotlib.collections.PolyCollection(verts, sizes=None, closed=True, **kwargs)[source]

Bases: matplotlib.collections._CollectionWithSizes

Parameters
vertslist of array-like

The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).

sizesarray-like, default: None

Squared scaling factors for the polygons. The coordinates of each polygon verts_i are multiplied by the square-root of the corresponding entry in sizes (i.e., sizes specify the scaling of areas). The scaling is applied before the Artist master transform.

closedbool, default: True

Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.

**kwargs

Forwarded to Collection.

add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters
funccallable

The callback function. It must have the signature:

def func(artist: Artist) -> Any

where artist is the calling Artist. Return values may exist but are ignored.

Returns
int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.

See also

remove_callback
autoscale()[source]

Autoscale the scalar limits on the norm instance using the current array

autoscale_None()[source]

Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None

propertyaxes

The Axes instance the artist resides in, or None.

propertycallbacksSM[source]
changed()[source]

Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.

colorbar

The last colorbar associated with this ScalarMappable. May be None.

contains(mouseevent)[source]

Test whether the mouse event occurred in the collection.

Returns bool, dict(ind=itemlist), where every item in itemlist contains the event.

convert_xunits(x)[source]

Convert x using the unit type of the xaxis.

If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.

convert_yunits(y)[source]

Convert y using the unit type of the yaxis.

If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

findobj(match=None, include_self=True)[source]

Find artist objects.

Recursively find all Artist instances contained in the artist.

Parameters
match

A filter criterion for the matches. This can be

  • None: Return all objects contained in artist.
  • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.
  • A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.

Returns
list of Artist
format_cursor_data(data)[source]

Return a string representation of data.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.

See also

get_cursor_data
get_agg_filter()[source]

Return filter function to be used for agg filter.

get_alpha()[source]

Return the alpha value used for blending - not supported on all backends.

get_animated()[source]

Return whether the artist is animated.

get_array()[source]

Return the array of values, that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.

get_capstyle()[source]
get_children()[source]

Return a list of the child Artists of this Artist.

get_clim()[source]

Return the values (min, max) that are mapped to the colormap limits.

get_clip_box()[source]

Return the clipbox.

get_clip_on()[source]

Return whether the artist uses clipping.

get_clip_path()[source]

Return the clip path.

get_cmap()[source]

Return the Colormap instance.

get_cursor_data(event)[source]

Return the cursor data for a given event.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.

Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.

The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.

Parameters
eventmatplotlib.backend_bases.MouseEvent
get_dashes()[source]

Alias for get_linestyle.

get_datalim(transData)[source]
get_ec()[source]

Alias for get_edgecolor.

get_edgecolor()[source]
get_edgecolors()[source]

Alias for get_edgecolor.

get_facecolor()[source]
get_facecolors()[source]

Alias for get_facecolor.

get_fc()[source]

Alias for get_facecolor.

get_figure()[source]

Return the Figure instance the artist belongs to.

get_fill()[source]

Return whether face is colored.

get_gid()[source]

Return the group id.

get_hatch()[source]

Return the current hatching pattern.

get_in_layout()[source]

Return boolean flag, True if artist is included in layout calculations.

E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

get_joinstyle()[source]
get_label()[source]

Return the label used for this artist in the legend.

get_linestyle()[source]
get_linestyles()[source]

Alias for get_linestyle.

get_linewidth()[source]
get_linewidths()[source]

Alias for get_linewidth.

get_ls()[source]

Alias for get_linestyle.

get_lw()[source]

Alias for get_linewidth.

get_offset_transform()[source]

Return the Transform instance used by this artist offset.

get_offsets()[source]

Return the offsets for the collection.

get_path_effects()[source]
get_paths()[source]
get_picker()[source]

Return the picking behavior of the artist.

The possible values are described in set_picker.

See also

set_picker, pickable, pick
get_pickradius()[source]
get_rasterized()[source]

Return whether the artist is to be rasterized.

get_sizes()[source]

Return the sizes ('areas') of the elements in the collection.

Returns
array

The 'area' of each element.

get_sketch_params()[source]

Return the sketch parameters for the artist.

Returns
tuple or None

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.
  • length: The length of the wiggle along the line.
  • randomness: The scale factor by which the length is shrunken or expanded.

Returns None if no sketch parameters were set.

get_snap()[source]

Return the snap setting.

See set_snap for details.

get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.

Parameters
rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

Returns
Bbox

The enclosing bounding box (in figure pixel coordinates).

get_transform()[source]

Return the Transform instance used by this artist.

get_transformed_clip_path_and_affine()[source]

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_transforms()[source]
get_url()[source]

Return the url.

get_urls()[source]

Return a list of URLs, one for each element of the collection.

The list contains None for elements without a URL. See Hyperlinks for an example.

get_visible()[source]

Return the visibility.

get_window_extent(renderer)[source]

Get the artist's bounding box in display space.

The bounding box' width and height are nonnegative.

Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

get_zorder()[source]

Return the artist's zorder.

have_units()[source]

Return whether units are set on any axis.

is_transform_set()[source]

Return whether the Artist has an explicitly set transform.

This is True after set_transform has been called.

propertymouseover

If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.

See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.

propertynorm
pchanged()[source]

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

pickable()[source]

Return whether the artist is pickable.

properties()[source]

Return a dictionary of all the properties of the artist.

remove()[source]

Remove the artist from the figure if possible.

The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

Note: relim will not see collections even if the collection was added to the axes with autolim = True.

Note: there is no support for removing the artist's legend entry.

remove_callback(oid)[source]

Remove a callback based on its observer id.

See also

add_callback
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, paths=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sizes=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, verts=<UNSET>, verts_and_codes=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array

alpha

array-like or scalar or None

animated

bool

antialiased or aa or antialiaseds

bool or list of bools

array

array-like or None

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

Bbox

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of rgba tuples

edgecolor or ec or edgecolors

color or list of colors or 'face'

facecolor or facecolors or fc

color or list of colors

figure

Figure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linestyle or dashes or linestyles or ls

str or tuple or list thereof

linewidth or linewidths or lw

float or list of floats

norm

Normalize or None

offset_transform

Transform

offsets

(N, 2) or (2,) array-like

path_effects

AbstractPathEffect

paths

list of array-like

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

ndarray or None

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

verts

list of array-like

verts_and_codes

unknown

visible

bool

zorder

float

set_aa(aa)[source]

Alias for set_antialiased.

set_agg_filter(filter_func)[source]

Set the agg filter.

Parameters
filter_funccallable

A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

set_alpha(alpha)[source]

Set the alpha value used for blending - not supported on all backends.

Parameters
alphaarray-like or scalar or None

All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)[source]

Set whether the artist is intended to be used in an animation.

If True, the artist is excluded from regular drawing of the figure. You have to call Figure.draw_artist / Axes.draw_artist explicitly on the artist. This appoach is used to speed up animations using blitting.

See also matplotlib.animation and Faster rendering by using blitting.

Parameters
bbool
set_antialiased(aa)[source]

Set the antialiasing state for rendering.

Parameters
aabool or list of bools
set_antialiaseds(aa)[source]

Alias for set_antialiased.

set_array(A)[source]

Set the value array from array-like A.

Parameters
Aarray-like or None

The values that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.

set_capstyle(cs)[source]

Set the CapStyle for the collection (for all its elements).

Parameters
csCapStyle or {'butt', 'projecting', 'round'}
set_clim(vmin=None, vmax=None)[source]

Set the norm limits for image scaling.

Parameters
vmin, vmaxfloat

The limits.

The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.

set_clip_box(clipbox)[source]

Set the artist's clip Bbox.

Parameters
clipboxBbox
set_clip_on(b)[source]

Set whether the artist uses clipping.

When False artists will be visible outside of the axes which can lead to unexpected results.

Parameters
bbool
set_clip_path(path, transform=None)[source]

Set the artist's clip path.

Parameters
pathPatch or Path or TransformedPath or None

The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed.

transformTransform, optional

Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform.

Notes

For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter.

set_cmap(cmap)[source]

Set the colormap for luminance data.

Parameters
cmapColormap or str or None
set_color(c)[source]

Set both the edgecolor and the facecolor.

Parameters
ccolor or list of rgba tuples

See also

Collection.set_facecolor, Collection.set_edgecolor

For setting the edge or face color individually.

set_dashes(ls)[source]

Alias for set_linestyle.

set_ec(c)[source]

Alias for set_edgecolor.

set_edgecolor(c)[source]

Set the edgecolor(s) of the collection.

Parameters
ccolor or list of colors or 'face'

The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.

set_edgecolors(c)[source]

Alias for set_edgecolor.

set_facecolor(c)[source]

Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.

If c is 'none', the patch will not be filled.

Parameters
ccolor or list of colors
set_facecolors(c)[source]

Alias for set_facecolor.

set_fc(c)[source]

Alias for set_facecolor.

set_figure(fig)[source]

Set the Figure instance the artist belongs to.

Parameters
figFigure
set_gid(gid)[source]

Set the (group) id for the artist.

Parameters
gidstr
set_hatch(hatch)[source]

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.

Parameters
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_in_layout(in_layout)[source]

Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

Parameters
in_layoutbool
set_joinstyle(js)[source]

Set the JoinStyle for the collection (for all its elements).

Parameters
jsJoinStyle or {'miter', 'round', 'bevel'}
set_label(s)[source]

Set a label that will be displayed in the legend.

Parameters
sobject

s will be converted to a string by calling str.

set_linestyle(ls)[source]

Set the linestyle(s) for the collection.

linestyle

description

'-' or 'solid'

solid line

'--' or 'dashed'

dashed line

'-.' or 'dashdot'

dash-dotted line

':' or 'dotted'

dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

Parameters
lsstr or tuple or list thereof

Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle for a complete description.

set_linestyles(ls)[source]

Alias for set_linestyle.

set_linewidth(lw)[source]

Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence

Parameters
lwfloat or list of floats
set_linewidths(lw)[source]

Alias for set_linewidth.

set_ls(ls)[source]

Alias for set_linestyle.

set_lw(lw)[source]

Alias for set_linewidth.

set_norm(norm)[source]

Set the normalization instance.

Parameters
normNormalize or None

Notes

If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.

set_offset_transform(transOffset)[source]

Set the artist offset transform.

Parameters
transOffsetTransform
set_offsets(offsets)[source]

Set the offsets for the collection.

Parameters
offsets(N, 2) or (2,) array-like
set_path_effects(path_effects)[source]

Set the path effects.

Parameters
path_effectsAbstractPathEffect
set_paths(verts, closed=True)[source]

Set the vertices of the polygons.

Parameters
vertslist of array-like

The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).

closedbool, default: True

Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.

set_picker(picker)[source]

Define the picking behavior of the artist.

Parameters
pickerNone or bool or float or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).
  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
  • A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

set_pickradius(pr)[source]

Set the pick radius used for containment tests.

Parameters
prfloat

Pick radius, in points.

set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output.

Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.

This setting is ignored for pixel-based output.

See also Rasterization for vector graphics.

Parameters
rasterizedbool
set_sizes(sizes, dpi=72.0)[source]

Set the sizes of each member of the collection.

Parameters
sizesndarray or None

The size to set for each element of the collection. The value is the 'area' of the element.

dpifloat, default: 72

The dpi of the canvas.

set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.

Parameters
scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.

lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)

randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.

set_snap(snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
set_transform(t)[source]

Set the artist transform.

Parameters
tTransform
set_url(url)[source]

Set the url for the artist.

Parameters
urlstr
set_urls(urls)[source]
Parameters
urlslist of str or None

Notes

URLs are currently only implemented by the SVG backend. They are ignored by all other backends.

set_verts(verts, closed=True)[source]

Set the vertices of the polygons.

Parameters
vertslist of array-like

The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).

closedbool, default: True

Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.

set_verts_and_codes(verts, codes)[source]

Initialize vertices with path codes.

set_visible(b)[source]

Set the artist's visibility.

Parameters
bbool
set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.

Parameters
levelfloat
propertystale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

propertysticky_edges

x and y sticky edge lists for autoscaling.

When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.

Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.

This attribute cannot be assigned to; however, the x and y lists can be modified in place as needed.

Examples

>>> artist.sticky_edges.x[:] = (xmin, xmax)
>>> artist.sticky_edges.y[:] = (ymin, ymax)
to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x.

In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.

There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.

If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).

update(props)[source]

Update this artist's properties from the dict props.

Parameters
propsdict
update_from(other)[source]

Copy properties from other to self.

update_scalarmappable()[source]

Update colors from the scalar mappable array, if any.

Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.

zorder=0
classmatplotlib.collections.QuadMesh(coordinates, *, antialiased=True, shading='flat', pickradius=0, **kwargs)[source]

Bases: matplotlib.collections.Collection

Class for the efficient drawing of a quadrilateral mesh.

A quadrilateral mesh is a grid of M by N adjacent qudrilaterals that are defined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) is defined by the vertices

   (m+1, n) ----------- (m+1, n+1)
      /                   /
     /                 /
    /               /
(m, n) -------- (m, n+1)

The mesh need not be regular and the polygons need not be convex.

Parameters
coordinates(M+1, N+1, 2) array-like

The vertices. coordinates[m, n] specifies the (x, y) coordinates of vertex (m, n).

antialiasedbool, default: True
shading{'flat', 'gouraud'}, default: 'flat'

Notes

Unlike other Collections, the default pickradius of QuadMesh is 0, i.e. contains checks whether the test point is within any of the mesh quadrilaterals.

There exists a deprecated API version QuadMesh(M, N, coords), where the dimensions are given explicitly and coords is a (M*N, 2) array-like. This has been deprecated in Matplotlib 3.5. The following describes the semantics of this deprecated API.

A quadrilateral mesh consists of a grid of vertices. The dimensions of this array are (meshWidth + 1, meshHeight + 1). Each vertex in the mesh has a different set of "mesh coordinates" representing its position in the topology of the mesh. For any values (m, n) such that 0 <= m <= meshWidth and 0 <= n <= meshHeight, the vertices at mesh coordinates (m, n), (m, n + 1), (m + 1, n + 1), and (m + 1, n) form one of the quadrilaterals in the mesh. There are thus (meshWidth * meshHeight) quadrilaterals in the mesh. The mesh need not be regular and the polygons need not be convex.

A quadrilateral mesh is represented by a (2 x ((meshWidth + 1) * (meshHeight + 1))) numpy array coordinates, where each row is the x and y coordinates of one of the vertices. To define the function that maps from a data point to its corresponding color, use the set_cmap() method. Each of these arrays is indexed in row-major order by the mesh coordinates of the vertex (or the mesh coordinates of the lower left vertex, in the case of the colors).

For example, the first entry in coordinates is the coordinates of the vertex at mesh coordinates (0, 0), then the one at (0, 1), then at (0, 2) .. (0, meshWidth), (1, 0), (1, 1), and so on.

Parameters
edgecolorscolor or list of colors, default: rcParams["patch.edgecolor"] (default: 'black')

Edge color for each patch making up the collection. The special value 'face' can be passed to make the edgecolor match the facecolor.

facecolorscolor or list of colors, default: rcParams["patch.facecolor"] (default: 'C0')

Face color for each patch making up the collection.

linewidthsfloat or list of floats, default: rcParams["patch.linewidth"] (default: 1.0)

Line width for each patch making up the collection.

linestylesstr or tuple or list thereof, default: 'solid'

Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink lengths in points. For examples, see Linestyles.

capstyleCapStyle-like, default: rcParams["patch.capstyle"]

Style to use for capping lines for all paths in the collection. Allowed values are {'butt', 'projecting', 'round'}.

joinstyleJoinStyle-like, default: rcParams["patch.joinstyle"]

Style to use for joining lines for all paths in the collection. Allowed values are {'miter', 'round', 'bevel'}.

antialiasedsbool or list of bool, default: rcParams["patch.antialiased"] (default: True)

Whether each patch in the collection should be drawn with antialiasing.

offsets(float, float) or list thereof, default: (0, 0)

A vector by which to translate each patch after rendering (default is no translation). The translation is performed in screen (pixel) coordinates (i.e. after the Artist's transform is applied).

transOffsetTransform, default: IdentityTransform

A single transform which will be applied to each offsets vector before it is used.

normNormalize, optional

Forwarded to ScalarMappable. The default of None means that the first draw call will set vmin and vmax using the minimum and maximum values of the data.

cmapColormap, optional

Forwarded to ScalarMappable. The default of None will result in rcParams["image.cmap"] (default: 'viridis') being used.

hatchstr, optional

Hatching pattern to use in filled paths, if any. Valid strings are ['/', '', '|', '-', '+', 'x', 'o', 'O', '.', '*']. See Hatch style reference for the meaning of each hatch type.

pickradiusfloat, default: 5.0

If pickradius <= 0, then Collection.contains will return True whenever the test point is inside of one of the polygons formed by the control points of a Path in the Collection. On the other hand, if it is greater than 0, then we instead check if the test point is contained in a stroke of width 2*pickradius following any of the Paths in the Collection.

urlslist of str, default: None

A URL for each patch to link to once drawn. Currently only works for the SVG backend. See Hyperlinks for examples.

zorderfloat, default: 1

The drawing order, shared by all Patches in the Collection. See Zorder Demo for all defaults and examples.

add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters
funccallable

The callback function. It must have the signature:

def func(artist: Artist) -> Any

where artist is the calling Artist. Return values may exist but are ignored.

Returns
int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.

See also

remove_callback
autoscale()[source]

Autoscale the scalar limits on the norm instance using the current array

autoscale_None()[source]

Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None

propertyaxes

The Axes instance the artist resides in, or None.

propertycallbacksSM[source]
changed()[source]

Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.

colorbar

The last colorbar associated with this ScalarMappable. May be None.

contains(mouseevent)[source]

Test whether the mouse event occurred in the collection.

Returns bool, dict(ind=itemlist), where every item in itemlist contains the event.

staticconvert_mesh_to_paths(meshWidth, meshHeight, coordinates)[source]

[Deprecated]

Notes

Deprecated since version 3.5:

convert_mesh_to_triangles(meshWidth, meshHeight, coordinates)[source]

[Deprecated]

Notes

Deprecated since version 3.5:

convert_xunits(x)[source]

Convert x using the unit type of the xaxis.

If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.

convert_yunits(y)[source]

Convert y using the unit type of the yaxis.

If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

findobj(match=None, include_self=True)[source]

Find artist objects.

Recursively find all Artist instances contained in the artist.

Parameters
match

A filter criterion for the matches. This can be

  • None: Return all objects contained in artist.
  • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.
  • A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.

Returns
list of Artist
format_cursor_data(data)[source]

Return a string representation of data.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.

See also

get_cursor_data
get_agg_filter()[source]

Return filter function to be used for agg filter.

get_alpha()[source]

Return the alpha value used for blending - not supported on all backends.

get_animated()[source]

Return whether the artist is animated.

get_array()[source]

Return the array of values, that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.

get_capstyle()[source]
get_children()[source]

Return a list of the child Artists of this Artist.

get_clim()[source]

Return the values (min, max) that are mapped to the colormap limits.

get_clip_box()[source]

Return the clipbox.

get_clip_on()[source]

Return whether the artist uses clipping.

get_clip_path()[source]

Return the clip path.

get_cmap()[source]

Return the Colormap instance.

get_coordinates()[source]

Return the vertices of the mesh as an (M+1, N+1, 2) array.

M, N are the number of quadrilaterals in the rows / columns of the mesh, corresponding to (M+1, N+1) vertices. The last dimension specifies the components (x, y).

get_cursor_data(event)[source]

Return the cursor data for a given event.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.

Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.

The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.

Parameters
eventmatplotlib.backend_bases.MouseEvent
get_dashes()[source]

Alias for get_linestyle.

get_datalim(transData)[source]
get_ec()[source]

Alias for get_edgecolor.

get_edgecolor()[source]
get_edgecolors()[source]

Alias for get_edgecolor.

get_facecolor()[source]
get_facecolors()[source]

Alias for get_facecolor.

get_fc()[source]

Alias for get_facecolor.

get_figure()[source]

Return the Figure instance the artist belongs to.

get_fill()[source]

Return whether face is colored.

get_gid()[source]

Return the group id.

get_hatch()[source]

Return the current hatching pattern.

get_in_layout()[source]

Return boolean flag, True if artist is included in layout calculations.

E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

get_joinstyle()[source]
get_label()[source]

Return the label used for this artist in the legend.

get_linestyle()[source]
get_linestyles()[source]

Alias for get_linestyle.

get_linewidth()[source]
get_linewidths()[source]

Alias for get_linewidth.

get_ls()[source]

Alias for get_linestyle.

get_lw()[source]

Alias for get_linewidth.

get_offset_transform()[source]

Return the Transform instance used by this artist offset.

get_offsets()[source]

Return the offsets for the collection.

get_path_effects()[source]
get_paths()[source]
get_picker()[source]

Return the picking behavior of the artist.

The possible values are described in set_picker.

See also

set_picker, pickable, pick
get_pickradius()[source]
get_rasterized()[source]

Return whether the artist is to be rasterized.

get_sketch_params()[source]

Return the sketch parameters for the artist.

Returns
tuple or None

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.
  • length: The length of the wiggle along the line.
  • randomness: The scale factor by which the length is shrunken or expanded.

Returns None if no sketch parameters were set.

get_snap()[source]

Return the snap setting.

See set_snap for details.

get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.

Parameters
rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

Returns
Bbox

The enclosing bounding box (in figure pixel coordinates).

get_transform()[source]

Return the Transform instance used by this artist.

get_transformed_clip_path_and_affine()[source]

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_transforms()[source]
get_url()[source]

Return the url.

get_urls()[source]

Return a list of URLs, one for each element of the collection.

The list contains None for elements without a URL. See Hyperlinks for an example.

get_visible()[source]

Return the visibility.

get_window_extent(renderer)[source]

Get the artist's bounding box in display space.

The bounding box' width and height are nonnegative.

Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

get_zorder()[source]

Return the artist's zorder.

have_units()[source]

Return whether units are set on any axis.

is_transform_set()[source]

Return whether the Artist has an explicitly set transform.

This is True after set_transform has been called.

propertymouseover

If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.

See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.

propertynorm
pchanged()[source]

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

pickable()[source]

Return whether the artist is pickable.

properties()[source]

Return a dictionary of all the properties of the artist.

remove()[source]

Remove the artist from the figure if possible.

The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

Note: relim will not see collections even if the collection was added to the axes with autolim = True.

Note: there is no support for removing the artist's legend entry.

remove_callback(oid)[source]

Remove a callback based on its observer id.

See also

add_callback
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array

alpha

array-like or scalar or None

animated

bool

antialiased or aa or antialiaseds

bool or list of bools

array

(M, N) array-like or M*N array-like

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

Bbox

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of rgba tuples

edgecolor or ec or edgecolors

color or list of colors or 'face'

facecolor or facecolors or fc

color or list of colors

figure

Figure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linestyle or dashes or linestyles or ls

str or tuple or list thereof

linewidth or linewidths or lw

float or list of floats

norm

Normalize or None

offset_transform

Transform

offsets

(N, 2) or (2,) array-like

path_effects

AbstractPathEffect

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

visible

bool

zorder

float

set_aa(aa)[source]

Alias for set_antialiased.

set_agg_filter(filter_func)[source]

Set the agg filter.

Parameters
filter_funccallable

A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

set_alpha(alpha)[source]

Set the alpha value used for blending - not supported on all backends.

Parameters
alphaarray-like or scalar or None

All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)[source]

Set whether the artist is intended to be used in an animation.

If True, the artist is excluded from regular drawing of the figure. You have to call Figure.draw_artist / Axes.draw_artist explicitly on the artist. This appoach is used to speed up animations using blitting.

See also matplotlib.animation and Faster rendering by using blitting.

Parameters
bbool
set_antialiased(aa)[source]

Set the antialiasing state for rendering.

Parameters
aabool or list of bools
set_antialiaseds(aa)[source]

Alias for set_antialiased.

set_array(A)[source]

Set the data values.

Parameters
A(M, N) array-like or M*N array-like

If the values are provided as a 2D grid, the shape must match the coordinates grid. If the values are 1D, they are reshaped to 2D. M, N follow from the coordinates grid, where the coordinates grid shape is (M, N) for 'gouraud' shading and (M+1, N+1) for 'flat' shading.

set_capstyle(cs)[source]

Set the CapStyle for the collection (for all its elements).

Parameters
csCapStyle or {'butt', 'projecting', 'round'}
set_clim(vmin=None, vmax=None)[source]

Set the norm limits for image scaling.

Parameters
vmin, vmaxfloat

The limits.

The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.

set_clip_box(clipbox)[source]

Set the artist's clip Bbox.

Parameters
clipboxBbox
set_clip_on(b)[source]

Set whether the artist uses clipping.

When False artists will be visible outside of the axes which can lead to unexpected results.

Parameters
bbool
set_clip_path(path, transform=None)[source]

Set the artist's clip path.

Parameters
pathPatch or Path or TransformedPath or None

The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed.

transformTransform, optional

Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform.

Notes

For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter.

set_cmap(cmap)[source]

Set the colormap for luminance data.

Parameters
cmapColormap or str or None
set_color(c)[source]

Set both the edgecolor and the facecolor.

Parameters
ccolor or list of rgba tuples

See also

Collection.set_facecolor, Collection.set_edgecolor

For setting the edge or face color individually.

set_dashes(ls)[source]

Alias for set_linestyle.

set_ec(c)[source]

Alias for set_edgecolor.

set_edgecolor(c)[source]

Set the edgecolor(s) of the collection.

Parameters
ccolor or list of colors or 'face'

The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.

set_edgecolors(c)[source]

Alias for set_edgecolor.

set_facecolor(c)[source]

Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.

If c is 'none', the patch will not be filled.

Parameters
ccolor or list of colors
set_facecolors(c)[source]

Alias for set_facecolor.

set_fc(c)[source]

Alias for set_facecolor.

set_figure(fig)[source]

Set the Figure instance the artist belongs to.

Parameters
figFigure
set_gid(gid)[source]

Set the (group) id for the artist.

Parameters
gidstr
set_hatch(hatch)[source]

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.

Parameters
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_in_layout(in_layout)[source]

Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

Parameters
in_layoutbool
set_joinstyle(js)[source]

Set the JoinStyle for the collection (for all its elements).

Parameters
jsJoinStyle or {'miter', 'round', 'bevel'}
set_label(s)[source]

Set a label that will be displayed in the legend.

Parameters
sobject

s will be converted to a string by calling str.

set_linestyle(ls)[source]

Set the linestyle(s) for the collection.

linestyle

description

'-' or 'solid'

solid line

'--' or 'dashed'

dashed line

'-.' or 'dashdot'

dash-dotted line

':' or 'dotted'

dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

Parameters
lsstr or tuple or list thereof

Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle for a complete description.

set_linestyles(ls)[source]

Alias for set_linestyle.

set_linewidth(lw)[source]

Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence

Parameters
lwfloat or list of floats
set_linewidths(lw)[source]

Alias for set_linewidth.

set_ls(ls)[source]

Alias for set_linestyle.

set_lw(lw)[source]

Alias for set_linewidth.

set_norm(norm)[source]

Set the normalization instance.

Parameters
normNormalize or None

Notes

If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.

set_offset_transform(transOffset)[source]

Set the artist offset transform.

Parameters
transOffsetTransform
set_offsets(offsets)[source]

Set the offsets for the collection.

Parameters
offsets(N, 2) or (2,) array-like
set_path_effects(path_effects)[source]

Set the path effects.

Parameters
path_effectsAbstractPathEffect
set_paths()[source]
set_picker(picker)[source]

Define the picking behavior of the artist.

Parameters
pickerNone or bool or float or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).
  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
  • A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

set_pickradius(pr)[source]

Set the pick radius used for containment tests.

Parameters
prfloat

Pick radius, in points.

set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output.

Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.

This setting is ignored for pixel-based output.

See also Rasterization for vector graphics.

Parameters
rasterizedbool
set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.

Parameters
scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.

lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)

randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.

set_snap(snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
set_transform(t)[source]

Set the artist transform.

Parameters
tTransform
set_url(url)[source]

Set the url for the artist.

Parameters
urlstr
set_urls(urls)[source]
Parameters
urlslist of str or None

Notes

URLs are currently only implemented by the SVG backend. They are ignored by all other backends.

set_visible(b)[source]

Set the artist's visibility.

Parameters
bbool
set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.

Parameters
levelfloat
propertystale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

propertysticky_edges

x and y sticky edge lists for autoscaling.

When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.

Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.

This attribute cannot be assigned to; however, the x and y lists can be modified in place as needed.

Examples

>>> artist.sticky_edges.x[:] = (xmin, xmax)
>>> artist.sticky_edges.y[:] = (ymin, ymax)
to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x.

In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.

There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.

If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).

update(props)[source]

Update this artist's properties from the dict props.

Parameters
propsdict
update_from(other)[source]

Copy properties from other to self.

update_scalarmappable()[source]

Update colors from the scalar mappable array, if any.

Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.

zorder=0
classmatplotlib.collections.RegularPolyCollection(numsides, rotation=0, sizes=(1,), **kwargs)[source]

Bases: matplotlib.collections._CollectionWithSizes

A collection of n-sided regular polygons.

Parameters
numsidesint

The number of sides of the polygon.

rotationfloat

The rotation of the polygon in radians.

sizestuple of float

The area of the circle circumscribing the polygon in points^2.

**kwargs

Forwarded to Collection.

Examples

See Lasso Demo for a complete example:

offsets = np.random.rand(20, 2)
facecolors = [cm.jet(x) for x in np.random.rand(20)]

collection = RegularPolyCollection(
    numsides=5, # a pentagon
    rotation=0, sizes=(50,),
    facecolors=facecolors,
    edgecolors=("black",),
    linewidths=(1,),
    offsets=offsets,
    transOffset=ax.transData,
    )
add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters
funccallable

The callback function. It must have the signature:

def func(artist: Artist) -> Any

where artist is the calling Artist. Return values may exist but are ignored.

Returns
int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.

See also

remove_callback
autoscale()[source]

Autoscale the scalar limits on the norm instance using the current array

autoscale_None()[source]

Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None

propertyaxes

The Axes instance the artist resides in, or None.

propertycallbacksSM[source]
changed()[source]

Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.

colorbar

The last colorbar associated with this ScalarMappable. May be None.

contains(mouseevent)[source]

Test whether the mouse event occurred in the collection.

Returns bool, dict(ind=itemlist), where every item in itemlist contains the event.

convert_xunits(x)[source]

Convert x using the unit type of the xaxis.

If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.

convert_yunits(y)[source]

Convert y using the unit type of the yaxis.

If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

findobj(match=None, include_self=True)[source]

Find artist objects.

Recursively find all Artist instances contained in the artist.

Parameters
match

A filter criterion for the matches. This can be

  • None: Return all objects contained in artist.
  • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.
  • A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.

Returns
list of Artist
format_cursor_data(data)[source]

Return a string representation of data.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.

See also

get_cursor_data
get_agg_filter()[source]

Return filter function to be used for agg filter.

get_alpha()[source]

Return the alpha value used for blending - not supported on all backends.

get_animated()[source]

Return whether the artist is animated.

get_array()[source]

Return the array of values, that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.

get_capstyle()[source]
get_children()[source]

Return a list of the child Artists of this Artist.

get_clim()[source]

Return the values (min, max) that are mapped to the colormap limits.

get_clip_box()[source]

Return the clipbox.

get_clip_on()[source]

Return whether the artist uses clipping.

get_clip_path()[source]

Return the clip path.

get_cmap()[source]

Return the Colormap instance.

get_cursor_data(event)[source]

Return the cursor data for a given event.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.

Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.

The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.

Parameters
eventmatplotlib.backend_bases.MouseEvent
get_dashes()[source]

Alias for get_linestyle.

get_datalim(transData)[source]
get_ec()[source]

Alias for get_edgecolor.

get_edgecolor()[source]
get_edgecolors()[source]

Alias for get_edgecolor.

get_facecolor()[source]
get_facecolors()[source]

Alias for get_facecolor.

get_fc()[source]

Alias for get_facecolor.

get_figure()[source]

Return the Figure instance the artist belongs to.

get_fill()[source]

Return whether face is colored.

get_gid()[source]

Return the group id.

get_hatch()[source]

Return the current hatching pattern.

get_in_layout()[source]

Return boolean flag, True if artist is included in layout calculations.

E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

get_joinstyle()[source]
get_label()[source]

Return the label used for this artist in the legend.

get_linestyle()[source]
get_linestyles()[source]

Alias for get_linestyle.

get_linewidth()[source]
get_linewidths()[source]

Alias for get_linewidth.

get_ls()[source]

Alias for get_linestyle.

get_lw()[source]

Alias for get_linewidth.

get_numsides()[source]
get_offset_transform()[source]

Return the Transform instance used by this artist offset.

get_offsets()[source]

Return the offsets for the collection.

get_path_effects()[source]
get_paths()[source]
get_picker()[source]

Return the picking behavior of the artist.

The possible values are described in set_picker.

See also

set_picker, pickable, pick
get_pickradius()[source]
get_rasterized()[source]

Return whether the artist is to be rasterized.

get_rotation()[source]
get_sizes()[source]

Return the sizes ('areas') of the elements in the collection.

Returns
array

The 'area' of each element.

get_sketch_params()[source]

Return the sketch parameters for the artist.

Returns
tuple or None

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.
  • length: The length of the wiggle along the line.
  • randomness: The scale factor by which the length is shrunken or expanded.

Returns None if no sketch parameters were set.

get_snap()[source]

Return the snap setting.

See set_snap for details.

get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.

Parameters
rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

Returns
Bbox

The enclosing bounding box (in figure pixel coordinates).

get_transform()[source]

Return the Transform instance used by this artist.

get_transformed_clip_path_and_affine()[source]

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_transforms()[source]
get_url()[source]

Return the url.

get_urls()[source]

Return a list of URLs, one for each element of the collection.

The list contains None for elements without a URL. See Hyperlinks for an example.

get_visible()[source]

Return the visibility.

get_window_extent(renderer)[source]

Get the artist's bounding box in display space.

The bounding box' width and height are nonnegative.

Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

get_zorder()[source]

Return the artist's zorder.

have_units()[source]

Return whether units are set on any axis.

is_transform_set()[source]

Return whether the Artist has an explicitly set transform.

This is True after set_transform has been called.

propertymouseover

If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.

See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.

propertynorm
pchanged()[source]

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

pickable()[source]

Return whether the artist is pickable.

properties()[source]

Return a dictionary of all the properties of the artist.

remove()[source]

Remove the artist from the figure if possible.

The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

Note: relim will not see collections even if the collection was added to the axes with autolim = True.

Note: there is no support for removing the artist's legend entry.

remove_callback(oid)[source]

Remove a callback based on its observer id.

See also

add_callback
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sizes=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array

alpha

array-like or scalar or None

animated

bool

antialiased or aa or antialiaseds

bool or list of bools

array

array-like or None

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

Bbox

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of rgba tuples

edgecolor or ec or edgecolors

color or list of colors or 'face'

facecolor or facecolors or fc

color or list of colors

figure

Figure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linestyle or dashes or linestyles or ls

str or tuple or list thereof

linewidth or linewidths or lw

float or list of floats

norm

Normalize or None

offset_transform

Transform

offsets

(N, 2) or (2,) array-like

path_effects

AbstractPathEffect

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

ndarray or None

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

visible

bool

zorder

float

set_aa(aa)[source]

Alias for set_antialiased.

set_agg_filter(filter_func)[source]

Set the agg filter.

Parameters
filter_funccallable

A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

set_alpha(alpha)[source]

Set the alpha value used for blending - not supported on all backends.

Parameters
alphaarray-like or scalar or None

All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)[source]

Set whether the artist is intended to be used in an animation.

If True, the artist is excluded from regular drawing of the figure. You have to call Figure.draw_artist / Axes.draw_artist explicitly on the artist. This appoach is used to speed up animations using blitting.

See also matplotlib.animation and Faster rendering by using blitting.

Parameters
bbool
set_antialiased(aa)[source]

Set the antialiasing state for rendering.

Parameters
aabool or list of bools
set_antialiaseds(aa)[source]

Alias for set_antialiased.

set_array(A)[source]

Set the value array from array-like A.

Parameters
Aarray-like or None

The values that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.

set_capstyle(cs)[source]

Set the CapStyle for the collection (for all its elements).

Parameters
csCapStyle or {'butt', 'projecting', 'round'}
set_clim(vmin=None, vmax=None)[source]

Set the norm limits for image scaling.

Parameters
vmin, vmaxfloat

The limits.

The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.

set_clip_box(clipbox)[source]

Set the artist's clip Bbox.

Parameters
clipboxBbox
set_clip_on(b)[source]

Set whether the artist uses clipping.

When False artists will be visible outside of the axes which can lead to unexpected results.

Parameters
bbool
set_clip_path(path, transform=None)[source]

Set the artist's clip path.

Parameters
pathPatch or Path or TransformedPath or None

The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed.

transformTransform, optional

Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform.

Notes

For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter.

set_cmap(cmap)[source]

Set the colormap for luminance data.

Parameters
cmapColormap or str or None
set_color(c)[source]

Set both the edgecolor and the facecolor.

Parameters
ccolor or list of rgba tuples

See also

Collection.set_facecolor, Collection.set_edgecolor

For setting the edge or face color individually.

set_dashes(ls)[source]

Alias for set_linestyle.

set_ec(c)[source]

Alias for set_edgecolor.

set_edgecolor(c)[source]

Set the edgecolor(s) of the collection.

Parameters
ccolor or list of colors or 'face'

The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.

set_edgecolors(c)[source]

Alias for set_edgecolor.

set_facecolor(c)[source]

Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.

If c is 'none', the patch will not be filled.

Parameters
ccolor or list of colors
set_facecolors(c)[source]

Alias for set_facecolor.

set_fc(c)[source]

Alias for set_facecolor.

set_figure(fig)[source]

Set the Figure instance the artist belongs to.

Parameters
figFigure
set_gid(gid)[source]

Set the (group) id for the artist.

Parameters
gidstr
set_hatch(hatch)[source]

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.

Parameters
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_in_layout(in_layout)[source]

Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

Parameters
in_layoutbool
set_joinstyle(js)[source]

Set the JoinStyle for the collection (for all its elements).

Parameters
jsJoinStyle or {'miter', 'round', 'bevel'}
set_label(s)[source]

Set a label that will be displayed in the legend.

Parameters
sobject

s will be converted to a string by calling str.

set_linestyle(ls)[source]

Set the linestyle(s) for the collection.

linestyle

description

'-' or 'solid'

solid line

'--' or 'dashed'

dashed line

'-.' or 'dashdot'

dash-dotted line

':' or 'dotted'

dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

Parameters
lsstr or tuple or list thereof

Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle for a complete description.

set_linestyles(ls)[source]

Alias for set_linestyle.

set_linewidth(lw)[source]

Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence

Parameters
lwfloat or list of floats
set_linewidths(lw)[source]

Alias for set_linewidth.

set_ls(ls)[source]

Alias for set_linestyle.

set_lw(lw)[source]

Alias for set_linewidth.

set_norm(norm)[source]

Set the normalization instance.

Parameters
normNormalize or None

Notes

If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.

set_offset_transform(transOffset)[source]

Set the artist offset transform.

Parameters
transOffsetTransform
set_offsets(offsets)[source]

Set the offsets for the collection.

Parameters
offsets(N, 2) or (2,) array-like
set_path_effects(path_effects)[source]

Set the path effects.

Parameters
path_effectsAbstractPathEffect
set_paths()[source]
set_picker(picker)[source]

Define the picking behavior of the artist.

Parameters
pickerNone or bool or float or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).
  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
  • A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

set_pickradius(pr)[source]

Set the pick radius used for containment tests.

Parameters
prfloat

Pick radius, in points.

set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output.

Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.

This setting is ignored for pixel-based output.

See also Rasterization for vector graphics.

Parameters
rasterizedbool
set_sizes(sizes, dpi=72.0)[source]

Set the sizes of each member of the collection.

Parameters
sizesndarray or None

The size to set for each element of the collection. The value is the 'area' of the element.

dpifloat, default: 72

The dpi of the canvas.

set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.

Parameters
scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.

lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)

randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.

set_snap(snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
set_transform(t)[source]

Set the artist transform.

Parameters
tTransform
set_url(url)[source]

Set the url for the artist.

Parameters
urlstr
set_urls(urls)[source]
Parameters
urlslist of str or None

Notes

URLs are currently only implemented by the SVG backend. They are ignored by all other backends.

set_visible(b)[source]

Set the artist's visibility.

Parameters
bbool
set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.

Parameters
levelfloat
propertystale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

propertysticky_edges

x and y sticky edge lists for autoscaling.

When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.

Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.

This attribute cannot be assigned to; however, the x and y lists can be modified in place as needed.

Examples

>>> artist.sticky_edges.x[:] = (xmin, xmax)
>>> artist.sticky_edges.y[:] = (ymin, ymax)
to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x.

In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.

There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.

If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).

update(props)[source]

Update this artist's properties from the dict props.

Parameters
propsdict
update_from(other)[source]

Copy properties from other to self.

update_scalarmappable()[source]

Update colors from the scalar mappable array, if any.

Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.

zorder=0
classmatplotlib.collections.StarPolygonCollection(numsides, rotation=0, sizes=(1,), **kwargs)[source]

Bases: matplotlib.collections.RegularPolyCollection

Draw a collection of regular stars with numsides points.

Parameters
numsidesint

The number of sides of the polygon.

rotationfloat

The rotation of the polygon in radians.

sizestuple of float

The area of the circle circumscribing the polygon in points^2.

**kwargs

Forwarded to Collection.

Examples

See Lasso Demo for a complete example:

offsets = np.random.rand(20, 2)
facecolors = [cm.jet(x) for x in np.random.rand(20)]

collection = RegularPolyCollection(
    numsides=5, # a pentagon
    rotation=0, sizes=(50,),
    facecolors=facecolors,
    edgecolors=("black",),
    linewidths=(1,),
    offsets=offsets,
    transOffset=ax.transData,
    )
add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters
funccallable

The callback function. It must have the signature:

def func(artist: Artist) -> Any

where artist is the calling Artist. Return values may exist but are ignored.

Returns
int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.

See also

remove_callback
autoscale()[source]

Autoscale the scalar limits on the norm instance using the current array

autoscale_None()[source]

Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None

propertyaxes

The Axes instance the artist resides in, or None.

propertycallbacksSM[source]
changed()[source]

Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.

colorbar

The last colorbar associated with this ScalarMappable. May be None.

contains(mouseevent)[source]

Test whether the mouse event occurred in the collection.

Returns bool, dict(ind=itemlist), where every item in itemlist contains the event.

convert_xunits(x)[source]

Convert x using the unit type of the xaxis.

If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.

convert_yunits(y)[source]

Convert y using the unit type of the yaxis.

If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

findobj(match=None, include_self=True)[source]

Find artist objects.

Recursively find all Artist instances contained in the artist.

Parameters
match

A filter criterion for the matches. This can be

  • None: Return all objects contained in artist.
  • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.
  • A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.

Returns
list of Artist
format_cursor_data(data)[source]

Return a string representation of data.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.

See also

get_cursor_data
get_agg_filter()[source]

Return filter function to be used for agg filter.

get_alpha()[source]

Return the alpha value used for blending - not supported on all backends.

get_animated()[source]

Return whether the artist is animated.

get_array()[source]

Return the array of values, that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.

get_capstyle()[source]
get_children()[source]

Return a list of the child Artists of this Artist.

get_clim()[source]

Return the values (min, max) that are mapped to the colormap limits.

get_clip_box()[source]

Return the clipbox.

get_clip_on()[source]

Return whether the artist uses clipping.

get_clip_path()[source]

Return the clip path.

get_cmap()[source]

Return the Colormap instance.

get_cursor_data(event)[source]

Return the cursor data for a given event.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.

Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.

The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.

Parameters
eventmatplotlib.backend_bases.MouseEvent
get_dashes()[source]

Alias for get_linestyle.

get_datalim(transData)[source]
get_ec()[source]

Alias for get_edgecolor.

get_edgecolor()[source]
get_edgecolors()[source]

Alias for get_edgecolor.

get_facecolor()[source]
get_facecolors()[source]

Alias for get_facecolor.

get_fc()[source]

Alias for get_facecolor.

get_figure()[source]

Return the Figure instance the artist belongs to.

get_fill()[source]

Return whether face is colored.

get_gid()[source]

Return the group id.

get_hatch()[source]

Return the current hatching pattern.

get_in_layout()[source]

Return boolean flag, True if artist is included in layout calculations.

E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

get_joinstyle()[source]
get_label()[source]

Return the label used for this artist in the legend.

get_linestyle()[source]
get_linestyles()[source]

Alias for get_linestyle.

get_linewidth()[source]
get_linewidths()[source]

Alias for get_linewidth.

get_ls()[source]

Alias for get_linestyle.

get_lw()[source]

Alias for get_linewidth.

get_numsides()[source]
get_offset_transform()[source]

Return the Transform instance used by this artist offset.

get_offsets()[source]

Return the offsets for the collection.

get_path_effects()[source]
get_paths()[source]
get_picker()[source]

Return the picking behavior of the artist.

The possible values are described in set_picker.

See also

set_picker, pickable, pick
get_pickradius()[source]
get_rasterized()[source]

Return whether the artist is to be rasterized.

get_rotation()[source]
get_sizes()[source]

Return the sizes ('areas') of the elements in the collection.

Returns
array

The 'area' of each element.

get_sketch_params()[source]

Return the sketch parameters for the artist.

Returns
tuple or None

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.
  • length: The length of the wiggle along the line.
  • randomness: The scale factor by which the length is shrunken or expanded.

Returns None if no sketch parameters were set.

get_snap()[source]

Return the snap setting.

See set_snap for details.

get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.

Parameters
rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

Returns
Bbox

The enclosing bounding box (in figure pixel coordinates).

get_transform()[source]

Return the Transform instance used by this artist.

get_transformed_clip_path_and_affine()[source]

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_transforms()[source]
get_url()[source]

Return the url.

get_urls()[source]

Return a list of URLs, one for each element of the collection.

The list contains None for elements without a URL. See Hyperlinks for an example.

get_visible()[source]

Return the visibility.

get_window_extent(renderer)[source]

Get the artist's bounding box in display space.

The bounding box' width and height are nonnegative.

Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

get_zorder()[source]

Return the artist's zorder.

have_units()[source]

Return whether units are set on any axis.

is_transform_set()[source]

Return whether the Artist has an explicitly set transform.

This is True after set_transform has been called.

propertymouseover

If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.

See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.

propertynorm
pchanged()[source]

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

pickable()[source]

Return whether the artist is pickable.

properties()[source]

Return a dictionary of all the properties of the artist.

remove()[source]

Remove the artist from the figure if possible.

The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

Note: relim will not see collections even if the collection was added to the axes with autolim = True.

Note: there is no support for removing the artist's legend entry.

remove_callback(oid)[source]

Remove a callback based on its observer id.

See also

add_callback
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sizes=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array

alpha

array-like or scalar or None

animated

bool

antialiased or aa or antialiaseds

bool or list of bools

array

array-like or None

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

Bbox

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of rgba tuples

edgecolor or ec or edgecolors

color or list of colors or 'face'

facecolor or facecolors or fc

color or list of colors

figure

Figure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linestyle or dashes or linestyles or ls

str or tuple or list thereof

linewidth or linewidths or lw

float or list of floats

norm

Normalize or None

offset_transform

Transform

offsets

(N, 2) or (2,) array-like

path_effects

AbstractPathEffect

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

ndarray or None

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

visible

bool

zorder

float

set_aa(aa)[source]

Alias for set_antialiased.

set_agg_filter(filter_func)[source]

Set the agg filter.

Parameters
filter_funccallable

A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

set_alpha(alpha)[source]

Set the alpha value used for blending - not supported on all backends.

Parameters
alphaarray-like or scalar or None

All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)[source]

Set whether the artist is intended to be used in an animation.

If True, the artist is excluded from regular drawing of the figure. You have to call Figure.draw_artist / Axes.draw_artist explicitly on the artist. This appoach is used to speed up animations using blitting.

See also matplotlib.animation and Faster rendering by using blitting.

Parameters
bbool
set_antialiased(aa)[source]

Set the antialiasing state for rendering.

Parameters
aabool or list of bools
set_antialiaseds(aa)[source]

Alias for set_antialiased.

set_array(A)[source]

Set the value array from array-like A.

Parameters
Aarray-like or None

The values that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.

set_capstyle(cs)[source]

Set the CapStyle for the collection (for all its elements).

Parameters
csCapStyle or {'butt', 'projecting', 'round'}
set_clim(vmin=None, vmax=None)[source]

Set the norm limits for image scaling.

Parameters
vmin, vmaxfloat

The limits.

The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.

set_clip_box(clipbox)[source]

Set the artist's clip Bbox.

Parameters
clipboxBbox
set_clip_on(b)[source]

Set whether the artist uses clipping.

When False artists will be visible outside of the axes which can lead to unexpected results.

Parameters
bbool
set_clip_path(path, transform=None)[source]

Set the artist's clip path.

Parameters
pathPatch or Path or TransformedPath or None

The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed.

transformTransform, optional

Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform.

Notes

For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter.

set_cmap(cmap)[source]

Set the colormap for luminance data.

Parameters
cmapColormap or str or None
set_color(c)[source]

Set both the edgecolor and the facecolor.

Parameters
ccolor or list of rgba tuples

See also

Collection.set_facecolor, Collection.set_edgecolor

For setting the edge or face color individually.

set_dashes(ls)[source]

Alias for set_linestyle.

set_ec(c)[source]

Alias for set_edgecolor.

set_edgecolor(c)[source]

Set the edgecolor(s) of the collection.

Parameters
ccolor or list of colors or 'face'

The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.

set_edgecolors(c)[source]

Alias for set_edgecolor.

set_facecolor(c)[source]

Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.

If c is 'none', the patch will not be filled.

Parameters
ccolor or list of colors
set_facecolors(c)[source]

Alias for set_facecolor.

set_fc(c)[source]

Alias for set_facecolor.

set_figure(fig)[source]

Set the Figure instance the artist belongs to.

Parameters
figFigure
set_gid(gid)[source]

Set the (group) id for the artist.

Parameters
gidstr
set_hatch(hatch)[source]

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.

Parameters
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_in_layout(in_layout)[source]

Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

Parameters
in_layoutbool
set_joinstyle(js)[source]

Set the JoinStyle for the collection (for all its elements).

Parameters
jsJoinStyle or {'miter', 'round', 'bevel'}
set_label(s)[source]

Set a label that will be displayed in the legend.

Parameters
sobject

s will be converted to a string by calling str.

set_linestyle(ls)[source]

Set the linestyle(s) for the collection.

linestyle

description

'-' or 'solid'

solid line

'--' or 'dashed'

dashed line

'-.' or 'dashdot'

dash-dotted line

':' or 'dotted'

dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

Parameters
lsstr or tuple or list thereof

Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle for a complete description.

set_linestyles(ls)[source]

Alias for set_linestyle.

set_linewidth(lw)[source]

Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence

Parameters
lwfloat or list of floats
set_linewidths(lw)[source]

Alias for set_linewidth.

set_ls(ls)[source]

Alias for set_linestyle.

set_lw(lw)[source]

Alias for set_linewidth.

set_norm(norm)[source]

Set the normalization instance.

Parameters
normNormalize or None

Notes

If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.

set_offset_transform(transOffset)[source]

Set the artist offset transform.

Parameters
transOffsetTransform
set_offsets(offsets)[source]

Set the offsets for the collection.

Parameters
offsets(N, 2) or (2,) array-like
set_path_effects(path_effects)[source]

Set the path effects.

Parameters
path_effectsAbstractPathEffect
set_paths()[source]
set_picker(picker)[source]

Define the picking behavior of the artist.

Parameters
pickerNone or bool or float or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).
  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
  • A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

set_pickradius(pr)[source]

Set the pick radius used for containment tests.

Parameters
prfloat

Pick radius, in points.

set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output.

Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.

This setting is ignored for pixel-based output.

See also Rasterization for vector graphics.

Parameters
rasterizedbool
set_sizes(sizes, dpi=72.0)[source]

Set the sizes of each member of the collection.

Parameters
sizesndarray or None

The size to set for each element of the collection. The value is the 'area' of the element.

dpifloat, default: 72

The dpi of the canvas.

set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.

Parameters
scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.

lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)

randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.

set_snap(snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
set_transform(t)[source]

Set the artist transform.

Parameters
tTransform
set_url(url)[source]

Set the url for the artist.

Parameters
urlstr
set_urls(urls)[source]
Parameters
urlslist of str or None

Notes

URLs are currently only implemented by the SVG backend. They are ignored by all other backends.

set_visible(b)[source]

Set the artist's visibility.

Parameters
bbool
set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.

Parameters
levelfloat
propertystale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

propertysticky_edges

x and y sticky edge lists for autoscaling.

When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.

Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.

This attribute cannot be assigned to; however, the x and y lists can be modified in place as needed.

Examples

>>> artist.sticky_edges.x[:] = (xmin, xmax)
>>> artist.sticky_edges.y[:] = (ymin, ymax)
to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x.

In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.

There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.

If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).

update(props)[source]

Update this artist's properties from the dict props.

Parameters
propsdict
update_from(other)[source]

Copy properties from other to self.

update_scalarmappable()[source]

Update colors from the scalar mappable array, if any.

Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.

zorder=0
classmatplotlib.collections.TriMesh(triangulation, **kwargs)[source]

Bases: matplotlib.collections.Collection

Class for the efficient drawing of a triangular mesh using Gouraud shading.

A triangular mesh is a Triangulation object.

Parameters
edgecolorscolor or list of colors, default: rcParams["patch.edgecolor"] (default: 'black')

Edge color for each patch making up the collection. The special value 'face' can be passed to make the edgecolor match the facecolor.

facecolorscolor or list of colors, default: rcParams["patch.facecolor"] (default: 'C0')

Face color for each patch making up the collection.

linewidthsfloat or list of floats, default: rcParams["patch.linewidth"] (default: 1.0)

Line width for each patch making up the collection.

linestylesstr or tuple or list thereof, default: 'solid'

Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink lengths in points. For examples, see Linestyles.

capstyleCapStyle-like, default: rcParams["patch.capstyle"]

Style to use for capping lines for all paths in the collection. Allowed values are {'butt', 'projecting', 'round'}.

joinstyleJoinStyle-like, default: rcParams["patch.joinstyle"]

Style to use for joining lines for all paths in the collection. Allowed values are {'miter', 'round', 'bevel'}.

antialiasedsbool or list of bool, default: rcParams["patch.antialiased"] (default: True)

Whether each patch in the collection should be drawn with antialiasing.

offsets(float, float) or list thereof, default: (0, 0)

A vector by which to translate each patch after rendering (default is no translation). The translation is performed in screen (pixel) coordinates (i.e. after the Artist's transform is applied).

transOffsetTransform, default: IdentityTransform

A single transform which will be applied to each offsets vector before it is used.

normNormalize, optional

Forwarded to ScalarMappable. The default of None means that the first draw call will set vmin and vmax using the minimum and maximum values of the data.

cmapColormap, optional

Forwarded to ScalarMappable. The default of None will result in rcParams["image.cmap"] (default: 'viridis') being used.

hatchstr, optional

Hatching pattern to use in filled paths, if any. Valid strings are ['/', '', '|', '-', '+', 'x', 'o', 'O', '.', '*']. See Hatch style reference for the meaning of each hatch type.

pickradiusfloat, default: 5.0

If pickradius <= 0, then Collection.contains will return True whenever the test point is inside of one of the polygons formed by the control points of a Path in the Collection. On the other hand, if it is greater than 0, then we instead check if the test point is contained in a stroke of width 2*pickradius following any of the Paths in the Collection.

urlslist of str, default: None

A URL for each patch to link to once drawn. Currently only works for the SVG backend. See Hyperlinks for examples.

zorderfloat, default: 1

The drawing order, shared by all Patches in the Collection. See Zorder Demo for all defaults and examples.

add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters
funccallable

The callback function. It must have the signature:

def func(artist: Artist) -> Any

where artist is the calling Artist. Return values may exist but are ignored.

Returns
int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.

See also

remove_callback
autoscale()[source]

Autoscale the scalar limits on the norm instance using the current array

autoscale_None()[source]

Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None

propertyaxes

The Axes instance the artist resides in, or None.

propertycallbacksSM[source]
changed()[source]

Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.

colorbar

The last colorbar associated with this ScalarMappable. May be None.

contains(mouseevent)[source]

Test whether the mouse event occurred in the collection.

Returns bool, dict(ind=itemlist), where every item in itemlist contains the event.

staticconvert_mesh_to_paths(tri)[source]

Convert a given mesh into a sequence of Path objects.

This function is primarily of use to implementers of backends that do not directly support meshes.

convert_xunits(x)[source]

Convert x using the unit type of the xaxis.

If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.

convert_yunits(y)[source]

Convert y using the unit type of the yaxis.

If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

findobj(match=None, include_self=True)[source]

Find artist objects.

Recursively find all Artist instances contained in the artist.

Parameters
match

A filter criterion for the matches. This can be

  • None: Return all objects contained in artist.
  • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.
  • A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.

Returns
list of Artist
format_cursor_data(data)[source]

Return a string representation of data.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.

See also

get_cursor_data
get_agg_filter()[source]

Return filter function to be used for agg filter.

get_alpha()[source]

Return the alpha value used for blending - not supported on all backends.

get_animated()[source]

Return whether the artist is animated.

get_array()[source]

Return the array of values, that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.

get_capstyle()[source]
get_children()[source]

Return a list of the child Artists of this Artist.

get_clim()[source]

Return the values (min, max) that are mapped to the colormap limits.

get_clip_box()[source]

Return the clipbox.

get_clip_on()[source]

Return whether the artist uses clipping.

get_clip_path()[source]

Return the clip path.

get_cmap()[source]

Return the Colormap instance.

get_cursor_data(event)[source]

Return the cursor data for a given event.

Note

This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.

Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.

Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.

The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.

Parameters
eventmatplotlib.backend_bases.MouseEvent
get_dashes()[source]

Alias for get_linestyle.

get_datalim(transData)[source]
get_ec()[source]

Alias for get_edgecolor.

get_edgecolor()[source]
get_edgecolors()[source]

Alias for get_edgecolor.

get_facecolor()[source]
get_facecolors()[source]

Alias for get_facecolor.

get_fc()[source]

Alias for get_facecolor.

get_figure()[source]

Return the Figure instance the artist belongs to.

get_fill()[source]

Return whether face is colored.

get_gid()[source]

Return the group id.

get_hatch()[source]

Return the current hatching pattern.

get_in_layout()[source]

Return boolean flag, True if artist is included in layout calculations.

E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

get_joinstyle()[source]
get_label()[source]

Return the label used for this artist in the legend.

get_linestyle()[source]
get_linestyles()[source]

Alias for get_linestyle.

get_linewidth()[source]
get_linewidths()[source]

Alias for get_linewidth.

get_ls()[source]

Alias for get_linestyle.

get_lw()[source]

Alias for get_linewidth.

get_offset_transform()[source]

Return the Transform instance used by this artist offset.

get_offsets()[source]

Return the offsets for the collection.

get_path_effects()[source]
get_paths()[source]
get_picker()[source]

Return the picking behavior of the artist.

The possible values are described in set_picker.

See also

set_picker, pickable, pick
get_pickradius()[source]
get_rasterized()[source]

Return whether the artist is to be rasterized.

get_sketch_params()[source]

Return the sketch parameters for the artist.

Returns
tuple or None

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.
  • length: The length of the wiggle along the line.
  • randomness: The scale factor by which the length is shrunken or expanded.

Returns None if no sketch parameters were set.

get_snap()[source]

Return the snap setting.

See set_snap for details.

get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.

Parameters
rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

Returns
Bbox

The enclosing bounding box (in figure pixel coordinates).

get_transform()[source]

Return the Transform instance used by this artist.

get_transformed_clip_path_and_affine()[source]

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_transforms()[source]
get_url()[source]

Return the url.

get_urls()[source]

Return a list of URLs, one for each element of the collection.

The list contains None for elements without a URL. See Hyperlinks for an example.

get_visible()[source]

Return the visibility.

get_window_extent(renderer)[source]

Get the artist's bounding box in display space.

The bounding box' width and height are nonnegative.

Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

get_zorder()[source]

Return the artist's zorder.

have_units()[source]

Return whether units are set on any axis.

is_transform_set()[source]

Return whether the Artist has an explicitly set transform.

This is True after set_transform has been called.

propertymouseover

If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.

See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.

propertynorm
pchanged()[source]

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

pickable()[source]

Return whether the artist is pickable.

properties()[source]

Return a dictionary of all the properties of the artist.

remove()[source]

Remove the artist from the figure if possible.

The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

Note: relim will not see collections even if the collection was added to the axes with autolim = True.

Note: there is no support for removing the artist's legend entry.

remove_callback(oid)[source]

Remove a callback based on its observer id.

See also

add_callback
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array

alpha

array-like or scalar or None

animated

bool

antialiased or aa or antialiaseds

bool or list of bools

array

array-like or None

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

Bbox

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of rgba tuples

edgecolor or ec or edgecolors

color or list of colors or 'face'

facecolor or facecolors or fc

color or list of colors

figure

Figure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linestyle or dashes or linestyles or ls

str or tuple or list thereof

linewidth or linewidths or lw

float or list of floats

norm

Normalize or None

offset_transform

Transform

offsets

(N, 2) or (2,) array-like

path_effects

AbstractPathEffect

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

visible

bool

zorder

float

set_aa(aa)[source]

Alias for set_antialiased.

set_agg_filter(filter_func)[source]

Set the agg filter.

Parameters
filter_funccallable

A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

set_alpha(alpha)[source]

Set the alpha value used for blending - not supported on all backends.

Parameters
alphaarray-like or scalar or None

All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)[source]

Set whether the artist is intended to be used in an animation.

If True, the artist is excluded from regular drawing of the figure. You have to call Figure.draw_artist / Axes.draw_artist explicitly on the artist. This appoach is used to speed up animations using blitting.

See also matplotlib.animation and Faster rendering by using blitting.

Parameters
bbool
set_antialiased(aa)[source]

Set the antialiasing state for rendering.

Parameters
aabool or list of bools
set_antialiaseds(aa)[source]

Alias for set_antialiased.

set_array(A)[source]

Set the value array from array-like A.

Parameters
Aarray-like or None

The values that are mapped to colors.

The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.

set_capstyle(cs)[source]

Set the CapStyle for the collection (for all its elements).

Parameters
csCapStyle or {'butt', 'projecting', 'round'}
set_clim(vmin=None, vmax=None)[source]

Set the norm limits for image scaling.

Parameters
vmin, vmaxfloat

The limits.

The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.

set_clip_box(clipbox)[source]

Set the artist's clip Bbox.

Parameters
clipboxBbox
set_clip_on(b)[source]

Set whether the artist uses clipping.

When False artists will be visible outside of the axes which can lead to unexpected results.

Parameters
bbool
set_clip_path(path, transform=None)[source]

Set the artist's clip path.

Parameters
pathPatch or Path or TransformedPath or None

The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed.

transformTransform, optional

Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform.

Notes

For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter.

set_cmap(cmap)[source]

Set the colormap for luminance data.

Parameters
cmapColormap or str or None
set_color(c)[source]

Set both the edgecolor and the facecolor.

Parameters
ccolor or list of rgba tuples

See also

Collection.set_facecolor, Collection.set_edgecolor

For setting the edge or face color individually.

set_dashes(ls)[source]

Alias for set_linestyle.

set_ec(c)[source]

Alias for set_edgecolor.

set_edgecolor(c)[source]

Set the edgecolor(s) of the collection.

Parameters
ccolor or list of colors or 'face'

The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.

set_edgecolors(c)[source]

Alias for set_edgecolor.

set_facecolor(c)[source]

Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.

If c is 'none', the patch will not be filled.

Parameters
ccolor or list of colors
set_facecolors(c)[source]

Alias for set_facecolor.

set_fc(c)[source]

Alias for set_facecolor.

set_figure(fig)[source]

Set the Figure instance the artist belongs to.

Parameters
figFigure
set_gid(gid)[source]

Set the (group) id for the artist.

Parameters
gidstr
set_hatch(hatch)[source]

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.

Parameters
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_in_layout(in_layout)[source]

Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide, Figure.tight_layout(), and fig.savefig(fname, bbox_inches='tight').

Parameters
in_layoutbool
set_joinstyle(js)[source]

Set the JoinStyle for the collection (for all its elements).

Parameters
jsJoinStyle or {'miter', 'round', 'bevel'}
set_label(s)[source]

Set a label that will be displayed in the legend.

Parameters
sobject

s will be converted to a string by calling str.

set_linestyle(ls)[source]

Set the linestyle(s) for the collection.

linestyle

description

'-' or 'solid'

solid line

'--' or 'dashed'

dashed line

'-.' or 'dashdot'

dash-dotted line

':' or 'dotted'

dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

Parameters
lsstr or tuple or list thereof

Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle for a complete description.

set_linestyles(ls)[source]

Alias for set_linestyle.

set_linewidth(lw)[source]

Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence

Parameters
lwfloat or list of floats
set_linewidths(lw)[source]

Alias for set_linewidth.

set_ls(ls)[source]

Alias for set_linestyle.

set_lw(lw)[source]

Alias for set_linewidth.

set_norm(norm)[source]

Set the normalization instance.

Parameters
normNormalize or None

Notes

If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.

set_offset_transform(transOffset)[source]

Set the artist offset transform.

Parameters
transOffsetTransform
set_offsets(offsets)[source]

Set the offsets for the collection.

Parameters
offsets(N, 2) or (2,) array-like
set_path_effects(path_effects)[source]

Set the path effects.

Parameters
path_effectsAbstractPathEffect
set_paths()[source]
set_picker(picker)[source]

Define the picking behavior of the artist.

Parameters
pickerNone or bool or float or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).
  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
  • A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

set_pickradius(pr)[source]

Set the pick radius used for containment tests.

Parameters
prfloat

Pick radius, in points.

set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output.

Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.

This setting is ignored for pixel-based output.

See also Rasterization for vector graphics.

Parameters
rasterizedbool
set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.

Parameters
scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.

lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)

randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.

set_snap(snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
set_transform(t)[source]

Set the artist transform.

Parameters
tTransform
set_url(url)[source]

Set the url for the artist.

Parameters
urlstr
set_urls(urls)[source]
Parameters
urlslist of str or None

Notes

URLs are currently only implemented by the SVG backend. They are ignored by all other backends.

set_visible(b)[source]

Set the artist's visibility.

Parameters
bbool
set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.

Parameters
levelfloat
propertystale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

propertysticky_edges

x and y sticky edge lists for autoscaling.

When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.

Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.

This attribute cannot be assigned to; however, the x and y lists can be modified in place as needed.

Examples

>>> artist.sticky_edges.x[:] = (xmin, xmax)
>>> artist.sticky_edges.y[:] = (ymin, ymax)
to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x.

In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.

There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.

If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).

update(props)[source]

Update this artist's properties from the dict props.

Parameters
propsdict
update_from(other)[source]

Copy properties from other to self.

update_scalarmappable()[source]

Update colors from the scalar mappable array, if any.

Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.

zorder=0

© 2012–2021 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.5.1/api/collections_api.html