matplotlib.collections#

Inheritance diagram of matplotlib.collections

Classes for the efficient drawing of large collections of objects thatshare most properties, e.g., a large number of line segments orpolygons.

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

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

Bases:RegularPolyCollection

Draw a collection of regular asterisks withnumsides 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 toCollection.

Examples

SeeLasso Demo for a complete example:

offsets=np.random.rand(20,2)facecolors=[cm.jet(x)forxinnp.random.rand(20)]collection=RegularPolyCollection(numsides=5,# a pentagonrotation=0,sizes=(50,),facecolors=facecolors,edgecolors=("black",),linewidths=(1,),offsets=offsets,offset_transform=ax.transData,)
add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

autoscale()[source]#

Autoscale the scalar limits on the norm instance using thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

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

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
get_label()[source]#

Return the label used for this artist in the legend.

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

Alias forget_linestyle.

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

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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

Return theTransform 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 inArtist.set_picker.

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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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 and two offsets from the bottom left corner of the image

alpha

array-like or float or None

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

array-like or None

capstyle

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

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

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 orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

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

label

object

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

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

path_effects

list ofAbstractPathEffect

paths

unknown

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

numpy.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 forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float 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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the value array from array-likeA.

Parameters:
Aarray-like or None

The values that are mapped to colors.

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the value arrayA.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

set_cmap(cmap)[source]#

Set the colormap for luminance data.

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

Set the edgecolor, facecolor and hatchcolor.

Changed in version 3.11:Now sets the hatchcolor as well.

Parameters:
ccolor or list of RGBA tuples

See also

Collection.set_facecolor,Collection.set_edgecolor,Collection.set_hatchcolor

For setting the facecolor, edgecolor, and hatchcolor individually.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization for vector graphics.

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

Set the sizes of each member of the collection.

Parameters:
sizesnumpy.ndarray or None

The size to set for each element of the collection. Thevalue 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored 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 zordervalues are drawn first.

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors that were directly set, as appropriate.

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

Bases:_CollectionWithSizes

A collection of circles, drawn using splines.

Parameters:
sizesfloat or array-like

The area of each circle in points^2.

**kwargs

Forwarded toCollection.

add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

autoscale()[source]#

Autoscale the scalar limits on the norm instance using thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

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

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
get_label()[source]#

Return the label used for this artist in the legend.

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

Alias forget_linestyle.

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

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

get_offset_transform()[source]#

Return theTransform 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 inArtist.set_picker.

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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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 and two offsets from the bottom left corner of the image

alpha

array-like or float or None

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

array-like or None

capstyle

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

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

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 orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

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

label

object

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

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

path_effects

list ofAbstractPathEffect

paths

unknown

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

numpy.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 forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float 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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the value array from array-likeA.

Parameters:
Aarray-like or None

The values that are mapped to colors.

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the value arrayA.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

set_cmap(cmap)[source]#

Set the colormap for luminance data.

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

Set the edgecolor, facecolor and hatchcolor.

Changed in version 3.11:Now sets the hatchcolor as well.

Parameters:
ccolor or list of RGBA tuples

See also

Collection.set_facecolor,Collection.set_edgecolor,Collection.set_hatchcolor

For setting the facecolor, edgecolor, and hatchcolor individually.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization for vector graphics.

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

Set the sizes of each member of the collection.

Parameters:
sizesnumpy.ndarray or None

The size to set for each element of the collection. Thevalue 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored 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 zordervalues are drawn first.

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors that were directly set, as appropriate.

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

Bases:ColorizingArtist

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

A Collection represents a sequence ofPatches that can be drawnmore efficiently together than individually. For example, when a singlepath is being drawn repeatedly at different offsets, the renderer cantypically execute adraw_marker() call much more efficiently than aseries of repeated calls todraw_path() with the offsets put inone-by-one.

Most properties of a collection can be configured per-element. Therefore,Collections have "plural" versions of many of the properties of aPatch(e.g.Collection.get_paths instead ofPatch.get_path). Exceptions arethezorder,hatch,pickradius,capstyle andjoinstyle 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 theith element of the collection is:

prop[i%len(prop)]

Each Collection can optionally be used as its ownScalarMappable bypassing thenorm andcmap parameters to its constructor. If theCollection'sScalarMappable matrix_A has been set (via a calltoCollection.set_array), then at draw time this internal scalarmappable will be used to set thefacecolors andedgecolors,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 specialvalue 'face' can be passed to make the edgecolor match thefacecolor.

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

Face color for each patch making up the collection.

hatchcolorscolor or list of colors, default:rcParams["hatch.color"] (default:'edge')

Hatch color for each patch making up the collection. The colorcan be set to the special value 'edge' to make the hatchcolor match theedgecolor.

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),

whereonoffseq is an even length tuple of on and off ink lengthsin points. For examples, seeLinestyles.

capstyleCapStyle-like, default: 'butt'

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

joinstyleJoinStyle-like, default: 'round'

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 withantialiasing.

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

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

offset_transformTransform, default:IdentityTransform

A single transform which will be applied to eachoffsets vectorbefore it is used.

cmap, norm

Data normalization and colormapping parameters. SeeScalarMappable for a detailed description.

hatchstr, optional

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

pickradiusfloat, default: 5.0

Ifpickradius<=0, thenCollection.contains will returnTrue whenever the test point is inside of one of the polygonsformed by the control points of a Path in the Collection. On theother hand, if it is greater than 0, then we instead check if thetest point is contained in a stroke of width2*pickradiusfollowing any of the Paths in the Collection.

urlslist of str, default: None

A URL for each patch to link to once drawn. Currently only worksfor the SVG backend. SeeHyperlinks forexamples.

zorderfloat, default: 1

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

**kwargs

Remaining keyword arguments will be used to set properties asCollection.set_{key}(val) for each key-value pair inkwargs.

add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

autoscale()[source]#

Autoscale the scalar limits on the norm instance using thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

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

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
get_label()[source]#

Return the label used for this artist in the legend.

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

Alias forget_linestyle.

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

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

get_offset_transform()[source]#

Return theTransform 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 inArtist.set_picker.

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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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 and two offsets from the bottom left corner of the image

alpha

array-like or float 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

BboxBase or None

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 ofcolor or 'face'

facecolor

color or list ofcolor

figure

Figure orSubFigure

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

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

label

object

linestyle

str or tuple or list thereof

linewidth

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform

Transform

offsets

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

path_effects

list ofAbstractPathEffect

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 forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float 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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the value array from array-likeA.

Parameters:
Aarray-like or None

The values that are mapped to colors.

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the value arrayA.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

set_cmap(cmap)[source]#

Set the colormap for luminance data.

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

Set the edgecolor, facecolor and hatchcolor.

Changed in version 3.11:Now sets the hatchcolor as well.

Parameters:
ccolor or list of RGBA tuples

See also

Collection.set_facecolor,Collection.set_edgecolor,Collection.set_hatchcolor

For setting the facecolor, edgecolor, and hatchcolor individually.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored 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 zordervalues are drawn first.

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors that were directly set, as appropriate.

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

Bases: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 theoffsets data units. 'xy' differs from all others inthat the angle as plotted varies with the aspect ratio, and equalsthe specified angle only when the aspect ratio is unity. Henceit behaves the same as theEllipse withaxes.transData as its transform.

**kwargs

Forwarded toCollection.

add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

autoscale()[source]#

Autoscale the scalar limits on the norm instance using thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_angles()[source]#

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

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

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

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_heights()[source]#

Set the lengths of second axes (e.g., minor axes).

get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
get_label()[source]#

Return the label used for this artist in the legend.

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

Alias forget_linestyle.

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

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

get_offset_transform()[source]#

Return theTransform 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 inArtist.set_picker.

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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_widths()[source]#

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

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,angles=<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>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,heights=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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>,widths=<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 and two offsets from the bottom left corner of the image

alpha

array-like or float or None

angles

unknown

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

array-like or None

capstyle

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

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

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 orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

heights

unknown

in_layout

bool

joinstyle

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

label

object

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

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

path_effects

list ofAbstractPathEffect

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

widths

unknown

zorder

float

set_aa(aa)[source]#

Alias forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float or None

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

set_angles(angles)[source]#

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

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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the value array from array-likeA.

Parameters:
Aarray-like or None

The values that are mapped to colors.

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the value arrayA.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

set_cmap(cmap)[source]#

Set the colormap for luminance data.

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

Set the edgecolor, facecolor and hatchcolor.

Changed in version 3.11:Now sets the hatchcolor as well.

Parameters:
ccolor or list of RGBA tuples

See also

Collection.set_facecolor,Collection.set_edgecolor,Collection.set_hatchcolor

For setting the facecolor, edgecolor, and hatchcolor individually.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_heights(heights)[source]#

Set the lengths of second axes (e.g., minor axes).

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored by all other backends.

set_visible(b)[source]#

Set the artist's visibility.

Parameters:
bbool
set_widths(widths)[source]#

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

set_zorder(level)[source]#

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

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors 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: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 anamplitude 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 orthogonaldirection.

lineoffsetfloat, default: 0

The offset of the center of the markers from the origin, in thedirection orthogonal toorientation.

linelengthfloat, default: 1

The total height of the marker (i.e. the marker stretches fromlineoffset-linelength/2 tolineoffset+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 ofcolor, 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),

whereonoffseq is an even length tuple of on and off inkin points.

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

Whether to use antialiasing for drawing the lines.

**kwargs

Forwarded toLineCollection.

Examples

(Sourcecode,2x.png,png)

add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

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 thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns 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.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

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

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gapcolor()[source]#
get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
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 forget_linestyle.

get_linewidth()[source]#

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

get_linewidths()[source]#

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

get_offset_transform()[source]#

Return theTransform 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 inArtist.set_picker.

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 anarray 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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,gapcolor=<UNSET>,gid=<UNSET>,hatch=<UNSET>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linelength=<UNSET>,lineoffset=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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 and two offsets from the bottom left corner of the image

alpha

array-like or float or None

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

array-like or None

capstyle

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

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list ofcolor

colors

color or list ofcolor

edgecolor orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gapcolor

color or list ofcolor or None

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

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

label

object

linelength

unknown

lineoffset

unknown

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

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

orientation

{'horizontal', 'vertical'}

path_effects

list ofAbstractPathEffect

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 forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float 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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the value array from array-likeA.

Parameters:
Aarray-like or None

The values that are mapped to colors.

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the value arrayA.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

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 ofcolor

Single color (all lines have same color), or asequence of RGBA tuples; if it is a sequence the lines willcycle through the sequence.

set_colors(c)[source]#

Set the edgecolor(s) of the LineCollection.

Parameters:
ccolor or list ofcolor

Single color (all lines have same color), or asequence of RGBA tuples; if it is a sequence the lines willcycle through the sequence.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
set_gapcolor(gapcolor)[source]#

Set a color to fill the gaps in the dashed line style.

Note

Striped lines are created by drawing two interleaved dashed lines.There can be overlaps between those two, which may result inartifacts when using transparency.

This functionality is experimental and may change.

Parameters:
gapcolorcolor or list ofcolor or None

The color with which to fill the gaps. If None, the gaps areunfilled.

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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored 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 zordervalues are drawn first.

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tohorizontal or vice versus.

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

Return a normalized RGBA array corresponding tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors that were directly set, as appropriate.

zorder=0#
classmatplotlib.collections.FillBetweenPolyCollection(t_direction,t,f1,f2,*,where=None,interpolate=False,step=None,**kwargs)[source]#

Bases:PolyCollection

PolyCollection that fills the area between two x- or y-curves.

Parameters:
t_direction{{'x', 'y'}}

The axes on which the variable lies.

  • 'x': the curves are(t,f1) and(t,f2).

  • 'y': the curves are(f1,t) and(f2,t).

tarray-like

Thet_direction coordinates of the nodes defining the curves.

f1array-like or float

The other coordinates of the nodes defining the first curve.

f2array-like or float

The other coordinates of the nodes defining the second curve.

wherearray-like of bool, optional

Definewhere to exclude some {dir} regions from being filled.The filled regions are defined by the coordinatest[where].More precisely, fill betweent[i] andt[i+1] ifwhere[i]andwhere[i+1]. Note that this definition impliesthat an isolatedTrue value between twoFalse values inwherewill not result in filling. Both sides of theTrue positionremain unfilled due to the adjacentFalse values.

interpolatebool, default: False

This option is only relevant ifwhere is used and the two curvesare crossing each other.

Semantically,where is often used forf1 >f2 orsimilar. By default, the nodes of the polygon defining the filledregion will only be placed at the positions in thet array.Such a polygon cannot describe the above semantics close to theintersection. The t-sections containing the intersection aresimply clipped.

Settinginterpolate toTrue will calculate the actualintersection point and extend the filled region up to this point.

step{{'pre', 'post', 'mid'}}, optional

Definestep if the filling should be a step function,i.e. constant in betweent. The value determines where thestep will occur:

  • 'pre': The f value is continued constantly to the left fromeveryt position, i.e. the interval(t[i-1],t[i]] has thevaluef[i].

  • 'post': The y value is continued constantly to the right fromeveryx position, i.e. the interval[t[i],t[i+1]) has thevaluef[i].

  • 'mid': Steps occur half-way between thet positions.

**kwargs

Forwarded toPolyCollection.

add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

autoscale()[source]#

Autoscale the scalar limits on the norm instance using thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

get_datalim(transData)[source]#

Calculate the data limits and return them as aBbox.

get_ec()[source]#

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
get_label()[source]#

Return the label used for this artist in the legend.

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

Alias forget_linestyle.

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

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

get_offset_transform()[source]#

Return theTransform 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 inArtist.set_picker.

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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,data=<UNSET>,edgecolor=<UNSET>,facecolor=<UNSET>,gid=<UNSET>,hatch=<UNSET>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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 and two offsets from the bottom left corner of the image

alpha

array-like or float or None

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

array-like or None

capstyle

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

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of RGBA tuples

data

array-like

edgecolor orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

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

label

object

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

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

path_effects

list ofAbstractPathEffect

paths

list of array-like

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

numpy.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 forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float 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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the value array from array-likeA.

Parameters:
Aarray-like or None

The values that are mapped to colors.

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the value arrayA.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

set_cmap(cmap)[source]#

Set the colormap for luminance data.

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

Set the edgecolor, facecolor and hatchcolor.

Changed in version 3.11:Now sets the hatchcolor as well.

Parameters:
ccolor or list of RGBA tuples

See also

Collection.set_facecolor,Collection.set_edgecolor,Collection.set_hatchcolor

For setting the facecolor, edgecolor, and hatchcolor individually.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_data(t,f1,f2,*,where=None)[source]#

Set new values for the two bounding curves.

Parameters:
tarray-like

Theself.t_direction coordinates of the nodes defining the curves.

f1array-like or float

The other coordinates of the nodes defining the first curve.

f2array-like or float

The other coordinates of the nodes defining the second curve.

wherearray-like of bool, optional

Definewhere to exclude some {dir} regions from being filled.The filled regions are defined by the coordinatest[where].More precisely, fill betweent[i] andt[i+1] ifwhere[i]andwhere[i+1]. Note that this definition impliesthat an isolatedTrue value between twoFalse values inwherewill not result in filling. Both sides of theTrue positionremain unfilled due to the adjacentFalse values.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
set_paths(verts,closed=True)[source]#

Set the vertices of the polygons.

Parameters:
vertslist of array-like

The sequence of polygons [verts0,verts1, ...] where eachelementverts_i defines the vertices of polygoni as a 2Darray-like of shape (M, 2).

closedbool, default: True

Whether the polygon should be closed by adding a CLOSEPOLYconnection 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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization for vector graphics.

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

Set the sizes of each member of the collection.

Parameters:
sizesnumpy.ndarray or None

The size to set for each element of the collection. Thevalue 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored 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 eachelementverts_i defines the vertices of polygoni as a 2Darray-like of shape (M, 2).

closedbool, default: True

Whether the polygon should be closed by adding a CLOSEPOLYconnection 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 zordervalues are drawn first.

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors that were directly set, as appropriate.

zorder=0#
classmatplotlib.collections.LineCollection(segments,*,zorder=2,**kwargs)[source]#

Bases:Collection

Represents a sequence ofLine2Ds that should be drawn together.

This class extendsCollection to represent a sequence ofLine2Ds instead of just a sequence ofPatchs.Just as inCollection, each property of aLineCollection may be eithera single value or a list of values. This list is then used cyclically foreach element of the LineCollection, so the property of theith elementof the collection is:

prop[i%len(prop)]

The properties of each member of aLineCollection default to their valuesinrcParams["lines.*"] instead ofrcParams["patch.*"], and the propertycolors isadded in place ofedgecolors.

Parameters:
segmentslist of (N, 2) array-like

A sequence[line0,line1,...] where each line is a (N, 2)-shapearray-like containing points:

line0=[(x0,y0),(x1,y1),...]

Each line can contain a different number of points.

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, notallowed).

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

Whether to use antialiasing for each line.

zorderfloat, default: 2

zorder of the lines once drawn.

facecolorscolor or list ofcolor, default: 'none'

When settingfacecolors, each line is interpreted as a boundaryfor an area, implicitly closing the path from the last point to thefirst point. The enclosed area is filled withfacecolor.In order to manually specify what should count as the "interior" ofeach line, please usePathCollection instead, where the"interior" can be specified by appropriate usage ofCLOSEPOLY.

**kwargs

Forwarded toCollection.

add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

autoscale()[source]#

Autoscale the scalar limits on the norm instance using thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

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

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gapcolor()[source]#
get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
get_label()[source]#

Return the label used for this artist in the legend.

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

Alias forget_linestyle.

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

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

get_offset_transform()[source]#

Return theTransform 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 inArtist.set_picker.

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 anarray 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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,gapcolor=<UNSET>,gid=<UNSET>,hatch=<UNSET>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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 and two offsets from the bottom left corner of the image

alpha

unknown

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

array-like or None

capstyle

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

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list ofcolor

colors

color or list ofcolor

edgecolor orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gapcolor

color or list ofcolor or None

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

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

label

object

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

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

path_effects

list ofAbstractPathEffect

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 forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float 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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the value array from array-likeA.

Parameters:
Aarray-like or None

The values that are mapped to colors.

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the value arrayA.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

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 ofcolor

Single color (all lines have same color), or asequence of RGBA tuples; if it is a sequence the lines willcycle through the sequence.

set_colors(c)[source]#

Set the edgecolor(s) of the LineCollection.

Parameters:
ccolor or list ofcolor

Single color (all lines have same color), or asequence of RGBA tuples; if it is a sequence the lines willcycle through the sequence.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
set_gapcolor(gapcolor)[source]#

Set a color to fill the gaps in the dashed line style.

Note

Striped lines are created by drawing two interleaved dashed lines.There can be overlaps between those two, which may result inartifacts when using transparency.

This functionality is experimental and may change.

Parameters:
gapcolorcolor or list ofcolor or None

The color with which to fill the gaps. If None, the gaps areunfilled.

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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored 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 zordervalues are drawn first.

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors that were directly set, as appropriate.

zorder=0#
classmatplotlib.collections.PatchCollection(patches,*,match_original=False,**kwargs)[source]#

Bases:Collection

A generic collection of patches.

PatchCollection draws faster than a large number of equivalent individualPatches. It also makes it easier to assign a colormap to a heterogeneouscollection of patches.

Parameters:
patcheslist ofPatch

A sequence of Patch objects. This list may includea heterogeneous assortment of different patch types.

match_originalbool, default: False

If True, use the colors and linewidths of the originalpatches. If False, new colors may be assigned byproviding the standard collection arguments, facecolor,edgecolor, linewidths, norm or cmap.

**kwargs

All other parameters are forwarded toCollection.

If any ofedgecolors,facecolors,linewidths,antialiasedsare None, they default to theirrcParams patch setting, insequence form.

Notes

The use ofScalarMappable functionality is optional.If theScalarMappable matrix_A has been set (viaa call toset_array), at draw time a call to scalarmappable will be made to set the face colors.

add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

autoscale()[source]#

Autoscale the scalar limits on the norm instance using thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

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

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
get_label()[source]#

Return the label used for this artist in the legend.

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

Alias forget_linestyle.

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

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

get_offset_transform()[source]#

Return theTransform 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 inArtist.set_picker.

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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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 and two offsets from the bottom left corner of the image

alpha

array-like or float or None

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

array-like or None

capstyle

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

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

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 orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

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

label

object

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

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

path_effects

list ofAbstractPathEffect

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 forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float 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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the value array from array-likeA.

Parameters:
Aarray-like or None

The values that are mapped to colors.

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the value arrayA.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

set_cmap(cmap)[source]#

Set the colormap for luminance data.

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

Set the edgecolor, facecolor and hatchcolor.

Changed in version 3.11:Now sets the hatchcolor as well.

Parameters:
ccolor or list of RGBA tuples

See also

Collection.set_facecolor,Collection.set_edgecolor,Collection.set_hatchcolor

For setting the facecolor, edgecolor, and hatchcolor individually.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored 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 zordervalues are drawn first.

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors that were directly set, as appropriate.

zorder=0#
classmatplotlib.collections.PathCollection(paths,sizes=None,**kwargs)[source]#

Bases:_CollectionWithSizes

A collection ofPaths, as created by e.g.scatter.

Parameters:
pathslist ofpath.Path

The paths that will make up theCollection.

sizesarray-like

The factor by which to scale each drawnPath. One unitsquared in the Path's data space is scaled to besizes**2points when rendered.

**kwargs

Forwarded toCollection.

add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

autoscale()[source]#

Autoscale the scalar limits on the norm instance using thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

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

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
get_label()[source]#

Return the label used for this artist in the legend.

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

Alias forget_linestyle.

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

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

get_offset_transform()[source]#

Return theTransform 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 inArtist.set_picker.

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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

legend_elements(prop='colors',num='auto',fmt=None,func=<functionPathCollection.<lambda>>,**kwargs)[source]#

Create legend handles and labels for a PathCollection.

Each legend handle is aLine2D representing the Path that was drawn,and each label is a string that represents the Path.

This is useful for obtaining a legend for ascatter plot;e.g.:

scatter=plt.scatter([1,2,3],[4,5,6],c=[7,2,3],num=None)plt.legend(*scatter.legend_elements())

creates three legend elements, one for each color with the numericalvalues passed toc as the labels.

Also see theAutomated legend creation example.

Parameters:
prop{"colors", "sizes"}, default: "colors"

If "colors", the legend handles will show the different colors ofthe collection. If "sizes", the legend will show the differentsizes. To set both, usekwargs to directly edit theLine2Dproperties.

numint, None, "auto" (default), array-like, orLocator

Target number of elements to create.If None, use all unique elements of the mappable array. If aninteger, target to usenum elements in the normed range.If"auto", try to determine which option better suits the natureof the data.The number of created elements may slightly deviate fromnum dueto aLocator being used to find useful locations.If a list or array, use exactly those elements for the legend.Finally, aLocator can be provided.

fmtstr,Formatter, or None (default)

The format or formatter to use for the labels. If a string must bea valid input for aStrMethodFormatter. If None (the default),use aScalarFormatter.

funcfunction, default:lambdax:x

Function to calculate the labels. Often the size (or color)argument toscatter will have been pre-processed by theuser using a functions=f(x) to make the markers visible;e.g.size=np.log10(x). Providing the inverse of thisfunction here allows that pre-processing to be inverted, so thatthe legend labels have the correct values; e.g.func=lambdax:10**x.

**kwargs

Allowed keyword arguments arecolor andsize. E.g. it may beuseful to set the color of the markers ifprop="sizes" is used;similarly to set the size of the markers ifprop="colors" isused. Any further parameters are passed onto theLine2Dinstance. This may be useful to e.g. specify a differentmarkeredgecolor oralpha for the legend handles.

Returns:
handleslist ofLine2D

Visual representation of each element of the legend.

labelslist of str

The string labels for elements of the legend.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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 and two offsets from the bottom left corner of the image

alpha

array-like or float or None

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

array-like or None

capstyle

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

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

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 orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

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

label

object

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

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

path_effects

list ofAbstractPathEffect

paths

unknown

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

numpy.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 forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float 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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the value array from array-likeA.

Parameters:
Aarray-like or None

The values that are mapped to colors.

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the value arrayA.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

set_cmap(cmap)[source]#

Set the colormap for luminance data.

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

Set the edgecolor, facecolor and hatchcolor.

Changed in version 3.11:Now sets the hatchcolor as well.

Parameters:
ccolor or list of RGBA tuples

See also

Collection.set_facecolor,Collection.set_edgecolor,Collection.set_hatchcolor

For setting the facecolor, edgecolor, and hatchcolor individually.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization for vector graphics.

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

Set the sizes of each member of the collection.

Parameters:
sizesnumpy.ndarray or None

The size to set for each element of the collection. Thevalue 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored 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 zordervalues are drawn first.

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors that were directly set, as appropriate.

zorder=0#
classmatplotlib.collections.PolyCollection(verts,sizes=None,*,closed=True,**kwargs)[source]#

Bases:_CollectionWithSizes

Parameters:
vertslist of array-like

The sequence of polygons [verts0,verts1, ...] where eachelementverts_i defines the vertices of polygoni as a 2Darray-like of shape (M, 2).

sizesarray-like, default: None

Squared scaling factors for the polygons. The coordinates of eachpolygonverts_i are multiplied by the square-root of thecorresponding entry insizes (i.e.,sizes specify the scalingof areas). The scaling is applied before the Artist mastertransform.

closedbool, default: True

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

**kwargs

Forwarded toCollection.

add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

autoscale()[source]#

Autoscale the scalar limits on the norm instance using thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

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

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
get_label()[source]#

Return the label used for this artist in the legend.

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

Alias forget_linestyle.

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

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

get_offset_transform()[source]#

Return theTransform 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 inArtist.set_picker.

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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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 and two offsets from the bottom left corner of the image

alpha

array-like or float or None

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

array-like or None

capstyle

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

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

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 orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

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

label

object

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

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

path_effects

list ofAbstractPathEffect

paths

list of array-like

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

numpy.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 forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float 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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the value array from array-likeA.

Parameters:
Aarray-like or None

The values that are mapped to colors.

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the value arrayA.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

set_cmap(cmap)[source]#

Set the colormap for luminance data.

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

Set the edgecolor, facecolor and hatchcolor.

Changed in version 3.11:Now sets the hatchcolor as well.

Parameters:
ccolor or list of RGBA tuples

See also

Collection.set_facecolor,Collection.set_edgecolor,Collection.set_hatchcolor

For setting the facecolor, edgecolor, and hatchcolor individually.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
set_paths(verts,closed=True)[source]#

Set the vertices of the polygons.

Parameters:
vertslist of array-like

The sequence of polygons [verts0,verts1, ...] where eachelementverts_i defines the vertices of polygoni as a 2Darray-like of shape (M, 2).

closedbool, default: True

Whether the polygon should be closed by adding a CLOSEPOLYconnection 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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization for vector graphics.

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

Set the sizes of each member of the collection.

Parameters:
sizesnumpy.ndarray or None

The size to set for each element of the collection. Thevalue 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored 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 eachelementverts_i defines the vertices of polygoni as a 2Darray-like of shape (M, 2).

closedbool, default: True

Whether the polygon should be closed by adding a CLOSEPOLYconnection 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 zordervalues are drawn first.

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors that were directly set, as appropriate.

zorder=0#
classmatplotlib.collections.PolyQuadMesh(coordinates,**kwargs)[source]#

Bases:_MeshData,PolyCollection

Class for drawing a quadrilateral mesh as individual Polygons.

A quadrilateral mesh is a grid of M by N adjacent quadrilaterals that aredefined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) isdefined 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) coordinatesof vertex (m, n).

Notes

UnlikeQuadMesh, this class will draw each cell as an individual Polygon.This is significantly slower, but allows for more flexibility when wantingto add additional properties to the cells, such as hatching.

Another difference fromQuadMesh is that if any of the vertices or dataof a cell are masked, that Polygon willnot be drawn and it won't be inthe list of paths returned.

Parameters:
vertslist of array-like

The sequence of polygons [verts0,verts1, ...] where eachelementverts_i defines the vertices of polygoni as a 2Darray-like of shape (M, 2).

sizesarray-like, default: None

Squared scaling factors for the polygons. The coordinates of eachpolygonverts_i are multiplied by the square-root of thecorresponding entry insizes (i.e.,sizes specify the scalingof areas). The scaling is applied before the Artist mastertransform.

closedbool, default: True

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

**kwargs

Forwarded toCollection.

add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

autoscale()[source]#

Autoscale the scalar limits on the norm instance using thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 themesh, 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

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

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
get_label()[source]#

Return the label used for this artist in the legend.

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

Alias forget_linestyle.

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

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

get_offset_transform()[source]#

Return theTransform 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 inArtist.set_picker.

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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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 and two offsets from the bottom left corner of the image

alpha

array-like or float or None

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

unknown

capstyle

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

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

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 orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

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

label

object

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

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

path_effects

list ofAbstractPathEffect

paths

list of array-like

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

numpy.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 forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float 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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the data values.

Parameters:
Aarray-like

The mesh data. Supported array shapes are:

  • (M, N) or (M*N,): a mesh with scalar data. The values are mappedto colors using normalization and a colormap. See parametersnorm,cmap,vmin,vmax.

  • (M, N, 3): an image with RGB values (0-1 float or 0-255 int).

  • (M, N, 4): an image with RGBA values (0-1 float or 0-255 int),i.e. including transparency.

If the values are provided as a 2D grid, the shape must match thecoordinates grid. If the values are 1D, they are reshaped to 2D.M, N follow from the coordinates grid, where the coordinates gridshape is (M, N) for 'gouraud'shading and (M+1, N+1) for 'flat'shading.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

set_cmap(cmap)[source]#

Set the colormap for luminance data.

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

Set the edgecolor, facecolor and hatchcolor.

Changed in version 3.11:Now sets the hatchcolor as well.

Parameters:
ccolor or list of RGBA tuples

See also

Collection.set_facecolor,Collection.set_edgecolor,Collection.set_hatchcolor

For setting the facecolor, edgecolor, and hatchcolor individually.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
set_paths(verts,closed=True)[source]#

Set the vertices of the polygons.

Parameters:
vertslist of array-like

The sequence of polygons [verts0,verts1, ...] where eachelementverts_i defines the vertices of polygoni as a 2Darray-like of shape (M, 2).

closedbool, default: True

Whether the polygon should be closed by adding a CLOSEPOLYconnection 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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization for vector graphics.

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

Set the sizes of each member of the collection.

Parameters:
sizesnumpy.ndarray or None

The size to set for each element of the collection. Thevalue 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored 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 eachelementverts_i defines the vertices of polygoni as a 2Darray-like of shape (M, 2).

closedbool, default: True

Whether the polygon should be closed by adding a CLOSEPOLYconnection 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 zordervalues are drawn first.

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors that were directly set, as appropriate.

zorder=0#
classmatplotlib.collections.QuadMesh(coordinates,*,antialiased=True,shading='flat',**kwargs)[source]#

Bases:_MeshData,Collection

Class for the efficient drawing of a quadrilateral mesh.

A quadrilateral mesh is a grid of M by N adjacent quadrilaterals that aredefined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) isdefined 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) coordinatesof vertex (m, n).

antialiasedbool, default: True
shading{'flat', 'gouraud'}, default: 'flat'

Notes

Unlike otherCollections, the defaultpickradius ofQuadMesh is 0,i.e.contains checks whether the test point is within any of themesh quadrilaterals.

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

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

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

Face color for each patch making up the collection.

hatchcolorscolor or list of colors, default:rcParams["hatch.color"] (default:'edge')

Hatch color for each patch making up the collection. The colorcan be set to the special value 'edge' to make the hatchcolor match theedgecolor.

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),

whereonoffseq is an even length tuple of on and off ink lengthsin points. For examples, seeLinestyles.

capstyleCapStyle-like, default: 'butt'

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

joinstyleJoinStyle-like, default: 'round'

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 withantialiasing.

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

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

offset_transformTransform, default:IdentityTransform

A single transform which will be applied to eachoffsets vectorbefore it is used.

cmap, norm

Data normalization and colormapping parameters. SeeScalarMappable for a detailed description.

hatchstr, optional

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

pickradiusfloat, default: 5.0

Ifpickradius<=0, thenCollection.contains will returnTrue whenever the test point is inside of one of the polygonsformed by the control points of a Path in the Collection. On theother hand, if it is greater than 0, then we instead check if thetest point is contained in a stroke of width2*pickradiusfollowing any of the Paths in the Collection.

urlslist of str, default: None

A URL for each patch to link to once drawn. Currently only worksfor the SVG backend. SeeHyperlinks forexamples.

zorderfloat, default: 1

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

**kwargs

Remaining keyword arguments will be used to set properties asCollection.set_{key}(val) for each key-value pair inkwargs.

add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

autoscale()[source]#

Autoscale the scalar limits on the norm instance using thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 themesh, 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

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

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
get_label()[source]#

Return the label used for this artist in the legend.

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

Alias forget_linestyle.

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

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

get_offset_transform()[source]#

Return theTransform 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 inArtist.set_picker.

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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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 and two offsets from the bottom left corner of the image

alpha

array-like or float or None

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

array-like

capstyle

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

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

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 orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

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

label

object

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

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

path_effects

list ofAbstractPathEffect

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 forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float 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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the data values.

Parameters:
Aarray-like

The mesh data. Supported array shapes are:

  • (M, N) or (M*N,): a mesh with scalar data. The values are mappedto colors using normalization and a colormap. See parametersnorm,cmap,vmin,vmax.

  • (M, N, 3): an image with RGB values (0-1 float or 0-255 int).

  • (M, N, 4): an image with RGBA values (0-1 float or 0-255 int),i.e. including transparency.

If the values are provided as a 2D grid, the shape must match thecoordinates grid. If the values are 1D, they are reshaped to 2D.M, N follow from the coordinates grid, where the coordinates gridshape is (M, N) for 'gouraud'shading and (M+1, N+1) for 'flat'shading.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

set_cmap(cmap)[source]#

Set the colormap for luminance data.

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

Set the edgecolor, facecolor and hatchcolor.

Changed in version 3.11:Now sets the hatchcolor as well.

Parameters:
ccolor or list of RGBA tuples

See also

Collection.set_facecolor,Collection.set_edgecolor,Collection.set_hatchcolor

For setting the facecolor, edgecolor, and hatchcolor individually.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored 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 zordervalues are drawn first.

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors that were directly set, as appropriate.

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

Bases:_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 toCollection.

Examples

SeeLasso Demo for a complete example:

offsets=np.random.rand(20,2)facecolors=[cm.jet(x)forxinnp.random.rand(20)]collection=RegularPolyCollection(numsides=5,# a pentagonrotation=0,sizes=(50,),facecolors=facecolors,edgecolors=("black",),linewidths=(1,),offsets=offsets,offset_transform=ax.transData,)
add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

autoscale()[source]#

Autoscale the scalar limits on the norm instance using thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

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

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
get_label()[source]#

Return the label used for this artist in the legend.

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

Alias forget_linestyle.

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

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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

Return theTransform 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 inArtist.set_picker.

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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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 and two offsets from the bottom left corner of the image

alpha

array-like or float or None

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

array-like or None

capstyle

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

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

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 orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

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

label

object

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

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

path_effects

list ofAbstractPathEffect

paths

unknown

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

numpy.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 forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float 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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the value array from array-likeA.

Parameters:
Aarray-like or None

The values that are mapped to colors.

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the value arrayA.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

set_cmap(cmap)[source]#

Set the colormap for luminance data.

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

Set the edgecolor, facecolor and hatchcolor.

Changed in version 3.11:Now sets the hatchcolor as well.

Parameters:
ccolor or list of RGBA tuples

See also

Collection.set_facecolor,Collection.set_edgecolor,Collection.set_hatchcolor

For setting the facecolor, edgecolor, and hatchcolor individually.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization for vector graphics.

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

Set the sizes of each member of the collection.

Parameters:
sizesnumpy.ndarray or None

The size to set for each element of the collection. Thevalue 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored 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 zordervalues are drawn first.

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors that were directly set, as appropriate.

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

Bases:RegularPolyCollection

Draw a collection of regular stars withnumsides 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 toCollection.

Examples

SeeLasso Demo for a complete example:

offsets=np.random.rand(20,2)facecolors=[cm.jet(x)forxinnp.random.rand(20)]collection=RegularPolyCollection(numsides=5,# a pentagonrotation=0,sizes=(50,),facecolors=facecolors,edgecolors=("black",),linewidths=(1,),offsets=offsets,offset_transform=ax.transData,)
add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

autoscale()[source]#

Autoscale the scalar limits on the norm instance using thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

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

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
get_label()[source]#

Return the label used for this artist in the legend.

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

Alias forget_linestyle.

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

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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

Return theTransform 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 inArtist.set_picker.

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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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 and two offsets from the bottom left corner of the image

alpha

array-like or float or None

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

array-like or None

capstyle

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

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

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 orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

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

label

object

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

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

path_effects

list ofAbstractPathEffect

paths

unknown

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

numpy.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 forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float 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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the value array from array-likeA.

Parameters:
Aarray-like or None

The values that are mapped to colors.

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the value arrayA.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

set_cmap(cmap)[source]#

Set the colormap for luminance data.

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

Set the edgecolor, facecolor and hatchcolor.

Changed in version 3.11:Now sets the hatchcolor as well.

Parameters:
ccolor or list of RGBA tuples

See also

Collection.set_facecolor,Collection.set_edgecolor,Collection.set_hatchcolor

For setting the facecolor, edgecolor, and hatchcolor individually.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization for vector graphics.

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

Set the sizes of each member of the collection.

Parameters:
sizesnumpy.ndarray or None

The size to set for each element of the collection. Thevalue 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored 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 zordervalues are drawn first.

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors that were directly set, as appropriate.

zorder=0#
classmatplotlib.collections.TriMesh(triangulation,**kwargs)[source]#

Bases:Collection

Class for the efficient drawing of a triangular mesh using Gouraud shading.

A triangular mesh is aTriangulation object.

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

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

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

Face color for each patch making up the collection.

hatchcolorscolor or list of colors, default:rcParams["hatch.color"] (default:'edge')

Hatch color for each patch making up the collection. The colorcan be set to the special value 'edge' to make the hatchcolor match theedgecolor.

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),

whereonoffseq is an even length tuple of on and off ink lengthsin points. For examples, seeLinestyles.

capstyleCapStyle-like, default: 'butt'

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

joinstyleJoinStyle-like, default: 'round'

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 withantialiasing.

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

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

offset_transformTransform, default:IdentityTransform

A single transform which will be applied to eachoffsets vectorbefore it is used.

cmap, norm

Data normalization and colormapping parameters. SeeScalarMappable for a detailed description.

hatchstr, optional

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

pickradiusfloat, default: 5.0

Ifpickradius<=0, thenCollection.contains will returnTrue whenever the test point is inside of one of the polygonsformed by the control points of a Path in the Collection. On theother hand, if it is greater than 0, then we instead check if thetest point is contained in a stroke of width2*pickradiusfollowing any of the Paths in the Collection.

urlslist of str, default: None

A URL for each patch to link to once drawn. Currently only worksfor the SVG backend. SeeHyperlinks forexamples.

zorderfloat, default: 1

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

**kwargs

Remaining keyword arguments will be used to set properties asCollection.set_{key}(val) for each key-value pair inkwargs.

add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

autoscale()[source]#

Autoscale the scalar limits on the norm instance using thecurrent array

autoscale_None()[source]#

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

propertyaxes#

TheAxes instance the artist resides in, orNone.

changed()[source]#

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

propertycmap#
propertycolorbar#

The last colorbar associated with this object. May be None

propertycolorizer#
contains(mouseevent)[source]#

Test whether the mouse event occurred in the collection.

Returnsbool,dict(ind=itemlist), where every item in itemlistcontains the event.

staticconvert_mesh_to_paths(tri)[source]#

Convert a given mesh into a sequence ofPath objects.

This function is primarily of use to implementers of backends that donot directly support meshes.

convert_xunits(x)[source]#

Convertx using the unit type of the xaxis.

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

convert_yunits(y)[source]#

Converty using the unit type of the yaxis.

If the artist is not contained in an Axes or if the yaxis does nothave 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_visiblereturns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

propertyfigure#

The (Sub)Figure that the artist is on. For more control, use theget_figure method.

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

Find artist objects.

Recursively find allArtist 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 signaturedefmatch(artist:Artist)->bool.The result will only contain artists for which the functionreturnsTrue.

  • A class instance: e.g.,Line2D. The result will only containartists of this class or its subclasses (isinstance check).

include_selfbool

Includeself in the list to be checked for a match.

Returns:
list ofArtist
format_cursor_data(data)[source]#

Return a string representation ofdata.

Note

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

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

get_aa()[source]#

Alias forget_antialiased.

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 allbackends.

get_animated()[source]#

Return whether the artist is animated.

get_antialiased()[source]#

Get the antialiasing state for rendering.

Returns:
array of bools
get_antialiaseds()[source]#

Alias forget_antialiased.

get_array()[source]#

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

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the array.

get_capstyle()[source]#

Return the cap style for the collection (for all its elements).

Returns:
{'butt', 'projecting', 'round'} or None
get_children()[source]#

Return a list of the childArtists of thisArtist.

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 theColormap 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 thismethod yourself.

Cursor data can be used by Artists to provide additional contextinformation for a given event. The default implementation just returnsNone.

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

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

Parameters:
eventMouseEvent
get_dashes()[source]#

Alias forget_linestyle.

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

Alias forget_edgecolor.

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

Alias forget_edgecolor.

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

Alias forget_facecolor.

get_fc()[source]#

Alias forget_facecolor.

get_figure(root=False)[source]#

Return theFigure orSubFigure instance the artist belongs to.

Parameters:
rootbool, default=False

If False, return the (Sub)Figure this artist is on. If True,return the root Figure for a nested tree of SubFigures.

get_fill()[source]#

Return whether face is colored.

get_gid()[source]#

Return the group id.

get_hatch()[source]#

Return the current hatching pattern.

get_hatch_linewidth()[source]#

Return the hatch linewidth.

get_hatchcolor()[source]#
get_in_layout()[source]#

Return boolean flag,True if artist is included in layoutcalculations.

E.g.Constrained layout guide,Figure.tight_layout(), andfig.savefig(fname,bbox_inches='tight').

get_joinstyle()[source]#

Return the join style for the collection (for all its elements).

Returns:
{'miter', 'round', 'bevel'} or None
get_label()[source]#

Return the label used for this artist in the legend.

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

Alias forget_linestyle.

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

Alias forget_linewidth.

get_ls()[source]#

Alias forget_linestyle.

get_lw()[source]#

Alias forget_linewidth.

get_mouseover()[source]#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

get_offset_transform()[source]#

Return theTransform 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 inArtist.set_picker.

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 thesource line.

  • length: The length of the wiggle along the line.

  • randomness: The scale factor by which the length isshrunken or expanded.

ReturnsNone if no sketch parameters were set.

get_snap()[source]#

Return the snap setting.

Seeset_snap for details.

get_tightbbox(renderer=None)[source]#

LikeArtist.get_window_extent, but includes any clipping.

Parameters:
rendererRendererBase subclass, optional

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

Returns:
Bbox or None

The enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.

get_transOffset()[source]#

Alias forget_offset_transform.

get_transform()[source]#

Return theTransform instance used by this artist.

get_transformed_clip_path_and_affine()[source]#

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

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 containsNone for elements without a URL. SeeHyperlinks for an example.

get_visible()[source]#

Return the visibility.

get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space.

The bounding box's width and height are non-negative.

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

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callmatplotlib.figure.Figure.savefig ormatplotlib.figure.Figure.draw_without_rendering to have Matplotlibcompute the rendered size.

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 isTrue afterset_transform has been called.

propertymouseover#

Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.

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 ifmouseevent is overthe 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.,withFigureCanvasBase.draw_idle. Callrelim toupdate the Axes limits if desired.

Note:relim will not see collections even if thecollection was added to the Axes withautolim = 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>,hatch_linewidth=<UNSET>,hatchcolor=<UNSET>,in_layout=<UNSET>,joinstyle=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<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 and two offsets from the bottom left corner of the image

alpha

array-like or float or None

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

array-like or None

capstyle

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

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

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 orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gid

str

hatch

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

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

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

label

object

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

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

path_effects

list ofAbstractPathEffect

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 forset_antialiased.

set_agg_filter(filter_func)[source]#

Set the agg filter.

Parameters:
filter_funccallable

A filter function, which takes a (m, n, depth) float arrayand a dpi value, and returns a (m, n, depth) array and twooffsets from the bottom left corner of the image

set_alpha(alpha)[source]#

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

Parameters:
alphaarray-like or float 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 callFigure.draw_artist /Axes.draw_artistexplicitly on the artist. This approach is used to speed up animationsusing blitting.

See alsomatplotlib.animation andFaster 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 forset_antialiased.

set_array(A)[source]#

Set the value array from array-likeA.

Parameters:
Aarray-like or None

The values that are mapped to colors.

The base classScalarMappable does not make any assumptions onthe dimensionality and shape of the value arrayA.

set_capstyle(cs)[source]#

Set theCapStyle 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.

For scalar data, the limits may also be passed as atuple (vmin,vmax) as a single positional argument.

set_clip_box(clipbox)[source]#

Set the artist's clipBbox.

Parameters:
clipboxBboxBase or None

Will typically be created from aTransformedBbox. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes) is the defaultclipping for an artist added to an Axes.

set_clip_on(b)[source]#

Set whether the artist uses clipping.

When False, artists will be visible outside the Axes whichcan lead to unexpected results.

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

Set the artist's clip path.

Parameters:
pathPatch orPath orTransformedPath or None

The clip path. If given aPath,transform must be provided aswell. IfNone, a previously set clip path is removed.

transformTransform, optional

Only used ifpath is aPath, in which case the givenPathis converted to aTransformedPath usingtransform.

Notes

For efficiency, ifpath is aRectangle this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone.

For technical reasons (support ofset), a tuple(path,transform) is also accepted as a single positionalparameter.

set_cmap(cmap)[source]#

Set the colormap for luminance data.

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

Set the edgecolor, facecolor and hatchcolor.

Changed in version 3.11:Now sets the hatchcolor as well.

Parameters:
ccolor or list of RGBA tuples

See also

Collection.set_facecolor,Collection.set_edgecolor,Collection.set_hatchcolor

For setting the facecolor, edgecolor, and hatchcolor individually.

set_dashes(ls)[source]#

Alias forset_linestyle.

set_ec(c)[source]#

Alias forset_edgecolor.

set_edgecolor(c)[source]#

Set the edgecolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'face'

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

set_edgecolors(c)[source]#

Alias forset_edgecolor.

set_facecolor(c)[source]#

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

Ifc is 'none', the patch will not be filled.

Parameters:
ccolor or list ofcolor
set_facecolors(c)[source]#

Alias forset_facecolor.

set_fc(c)[source]#

Alias forset_facecolor.

set_figure(fig)[source]#

Set theFigure orSubFigure instance the artist belongs to.

Parameters:
figFigure orSubFigure
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:

/-diagonalhatching\-backdiagonal|-vertical--horizontal+-crossedx-crosseddiagonalo-smallcircleO-largecircle.-dots*-stars

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

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

Parameters:
hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
set_hatch_linewidth(lw)[source]#

Set the hatch linewidth.

set_hatchcolor(c)[source]#

Set the hatchcolor(s) of the collection.

Parameters:
ccolor or list ofcolor or 'edge'

The collection hatchcolor(s). If a sequence, the patches cyclethrough it.

set_in_layout(in_layout)[source]#

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

Parameters:
in_layoutbool
set_joinstyle(js)[source]#

Set theJoinStyle 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 callingstr.

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),

whereonoffseq 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)}. SeeLine2D.set_linestyle for acomplete description.

set_linestyles(ls)[source]#

Alias forset_linestyle.

set_linewidth(lw)[source]#

Set the linewidth(s) for the collection.lw can be a scalaror a sequence; if it is a sequence the patches will cyclethrough the sequence

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

Alias forset_linewidth.

set_ls(ls)[source]#

Alias forset_linestyle.

set_lw(lw)[source]#

Alias forset_linewidth.

set_mouseover(mouseover)[source]#

Set whether this artist is queried for custom context information whenthe mouse cursor moves over it.

Parameters:
mouseoverbool
set_norm(norm)[source]#

Set the normalization instance.

Parameters:
normNormalize or str or None

Notes

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

set_offset_transform(offset_transform)[source]#

Set the artist offset transform.

Parameters:
offset_transformTransform
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_effectslist ofAbstractPathEffect
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: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

  • A function: If picker is callable, it is a user suppliedfunction which determines whether the artist is hit by themouse event:

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

set_pickradius(pickradius)[source]#

Set the pick radius used for containment tests.

Parameters:
pickradiusfloat

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 toenable this on an artist that does not support it, the command has noeffect and a warning will be issued.

This setting is ignored for pixel-based output.

See alsoRasterization 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 sourceline, in pixels. If scale isNone, or not provided, nosketch 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 orexpanded (default 16.0)

The PGF backend uses this argument as an RNG seed and not asdescribed 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 inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

set_transOffset(offset_transform)[source]#

Alias forset_offset_transform.

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 areignored 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 zordervalues are drawn first.

Parameters:
levelfloat
propertystale#

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

propertysticky_edges#

x andy sticky edge lists for autoscaling.

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

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

This attribute cannot be assigned to; however, thex andylists 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 tox.

In the normal case,x is a 1D or 2D sequence of scalars, andthe correspondingndarray of RGBA values will be returned,based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are alreadyRGB or RGBA, such as might have been read from an image file.Ifx is anndarray with 3 dimensions,and the last dimension is either 3 or 4, then it will betreated as an RGB or RGBA array, and no mapping will be done.The array can beuint8, or it can be floats withvalues in the 0-1 range; otherwise a ValueError will be raised.Any NaNs or masked elements will be set to 0 alpha.If the last dimension is 3, thealpha kwarg (defaulting to 1)will be used to fill in the transparency. If the last dimensionis 4, thealpha kwarg is ignored; it does notreplace the preexisting alpha. A ValueError will be raisedif the third dimension is other than 3 or 4.

In either case, ifbytes isFalse (default), the RGBAarray will be floats in the 0-1 range; if it isTrue,the returned RGBA array will beuint8 in the 0 to 255 range.

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

update(props)[source]#

Update this artist's properties from the dictprops.

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/orcolors that were directly set, as appropriate.

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

Base class for collections that have an array of sizes.

get_sizes()[source]#

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

Returns:
array

The 'area' of each element.

set_sizes(sizes,dpi=72.0)[source]#

Set the sizes of each member of the collection.

Parameters:
sizesnumpy.ndarray or None

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

dpifloat, default: 72

The dpi of the canvas.

classmatplotlib.collections._MeshData(coordinates,*,shading='flat')[source]#

Class for managing the two dimensional coordinates of Quadrilateral meshesand the associated data with them. This class is a mixin and is intended tobe used with another collection that will implement the draw separately.

A quadrilateral mesh is a grid of M by N adjacent quadrilaterals that aredefined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) isdefined 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) coordinatesof vertex (m, n).

shading{'flat', 'gouraud'}, default: 'flat'
set_array(A)[source]#

Set the data values.

Parameters:
Aarray-like

The mesh data. Supported array shapes are:

  • (M, N) or (M*N,): a mesh with scalar data. The values are mappedto colors using normalization and a colormap. See parametersnorm,cmap,vmin,vmax.

  • (M, N, 3): an image with RGB values (0-1 float or 0-255 int).

  • (M, N, 4): an image with RGBA values (0-1 float or 0-255 int),i.e. including transparency.

If the values are provided as a 2D grid, the shape must match thecoordinates grid. If the values are 1D, they are reshaped to 2D.M, N follow from the coordinates grid, where the coordinates gridshape is (M, N) for 'gouraud'shading and (M+1, N+1) for 'flat'shading.

On this page