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 to
Collection
.
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 the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
array-like or float or None
bool
bool or list of bools
array-like or None
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Nonecolor or list of RGBA tuples
edgecolor
orec
oredgecolors
facecolor
orfacecolors
orfc
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
linestyle
ordashes
orlinestyles
orls
str or tuple or list thereof
linewidth
orlinewidths
orlw
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
list of
AbstractPathEffect
unknown
None or bool or float or callable
float
bool
numpy.ndarray
or None(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
bool
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 class
ScalarMappable
does not make any assumptions onthe dimensionality and shape of the value arrayA.
- set_capstyle(cs)[source]#
Set the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- 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 for
set_linestyle
.
- set_ec(c)[source]#
Alias for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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:
- sizes
numpy.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.
- sizes
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- to_rgba(x,alpha=None,bytes=False,norm=True)[source]#
Return a normalized RGBA array corresponding tox.
In the normal case,x is a 1D or 2D sequence of scalars, andthe corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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 to
Collection
.
- add_callback(func)[source]#
Add a callback function that will be called whenever one of the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
array-like or float or None
bool
bool or list of bools
array-like or None
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Nonecolor or list of RGBA tuples
edgecolor
orec
oredgecolors
facecolor
orfacecolors
orfc
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
linestyle
ordashes
orlinestyles
orls
str or tuple or list thereof
linewidth
orlinewidths
orlw
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
list of
AbstractPathEffect
unknown
None or bool or float or callable
float
bool
numpy.ndarray
or None(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
bool
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 class
ScalarMappable
does not make any assumptions onthe dimensionality and shape of the value arrayA.
- set_capstyle(cs)[source]#
Set the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- 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 for
set_linestyle
.
- set_ec(c)[source]#
Alias for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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:
- sizes
numpy.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.
- sizes
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- to_rgba(x,alpha=None,bytes=False,norm=True)[source]#
Return a normalized RGBA array corresponding tox.
In the normal case,x is a 1D or 2D sequence of scalars, andthe corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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 of
Patch
es 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 a
Patch
(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 the
i
th element of the collection is:prop[i%len(prop)]
Each Collection can optionally be used as its own
ScalarMappable
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.
- capstyle
CapStyle
-like, default: 'butt' Style to use for capping lines for all paths in the collection.Allowed values are {'butt', 'projecting', 'round'}.
- joinstyle
JoinStyle
-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_transform
Transform
, default:IdentityTransform
A single transform which will be applied to eachoffsets vectorbefore it is used.
- cmap, norm
Data normalization and colormapping parameters. See
ScalarMappable
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
If
pickradius<=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*pickradius
following any of the Paths in the Collection.- urlslist of str, default: None
A URL for each patch to link to once drawn. Currently only 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 as
Collection.set_{key}(val)
for each key-value pair inkwargs.
- edgecolorscolor or list of colors, default:
- add_callback(func)[source]#
Add a callback function that will be called whenever one of the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
array-like or float or None
bool
bool or list of bools
array-like or None
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Nonecolor or list of RGBA tuples
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
str or tuple or list thereof
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
list of
AbstractPathEffect
unknown
None or bool or float or callable
float
bool
(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
bool
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 class
ScalarMappable
does not make any assumptions onthe dimensionality and shape of the value arrayA.
- set_capstyle(cs)[source]#
Set the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- 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 for
set_linestyle
.
- set_ec(c)[source]#
Alias for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- to_rgba(x,alpha=None,bytes=False,norm=True)[source]#
Return a normalized RGBA array corresponding tox.
In the normal case,x is a 1D or 2D sequence of scalars, andthe corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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 the
Ellipse
withaxes.transData
as its transform.- **kwargs
Forwarded to
Collection
.
- add_callback(func)[source]#
Add a callback function that will be called whenever one of the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
array-like or float or None
unknown
bool
bool or list of bools
array-like or None
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Nonecolor or list of RGBA tuples
edgecolor
orec
oredgecolors
facecolor
orfacecolors
orfc
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
linestyle
ordashes
orlinestyles
orls
str or tuple or list thereof
linewidth
orlinewidths
orlw
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
list of
AbstractPathEffect
unknown
None or bool or float or callable
float
bool
(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
bool
unknown
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 class
ScalarMappable
does not make any assumptions onthe dimensionality and shape of the value arrayA.
- set_capstyle(cs)[source]#
Set the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- 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 for
set_linestyle
.
- set_ec(c)[source]#
Alias for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- to_rgba(x,alpha=None,bytes=False,norm=True)[source]#
Return a normalized RGBA array corresponding tox.
In the normal case,x is a 1D or 2D sequence of scalars, andthe corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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 from
lineoffset-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 to
LineCollection
.
Examples
- add_callback(func)[source]#
Add a callback function that will be called whenever one of the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
array-like or float or None
bool
bool or list of bools
array-like or None
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Noneedgecolor
orec
oredgecolors
facecolor
orfacecolors
orfc
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
unknown
unknown
linestyle
ordashes
orlinestyles
orls
str or tuple or list thereof
linewidth
orlinewidths
orlw
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
{'horizontal', 'vertical'}
list of
AbstractPathEffect
unknown
None or bool or float or callable
float
unknown
bool
unknown
(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
unknown
bool
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 class
ScalarMappable
does not make any assumptions onthe dimensionality and shape of the value arrayA.
- set_capstyle(cs)[source]#
Set the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- set_dashes(ls)[source]#
Alias for
set_linestyle
.
- set_ec(c)[source]#
Alias for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- switch_orientation()[source]#
Switch the orientation of the event line, either from vertical 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 corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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
The
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 coordinates
t[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 to
PolyCollection
.
See also
- add_callback(func)[source]#
Add a callback function that will be called whenever one of the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
array-like or float or None
bool
bool or list of bools
array-like or None
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Nonecolor or list of RGBA tuples
array-like
edgecolor
orec
oredgecolors
facecolor
orfacecolors
orfc
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
linestyle
ordashes
orlinestyles
orls
str or tuple or list thereof
linewidth
orlinewidths
orlw
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
list of
AbstractPathEffect
list of array-like
None or bool or float or callable
float
bool
numpy.ndarray
or None(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
list of array-like
unknown
bool
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 class
ScalarMappable
does not make any assumptions onthe dimensionality and shape of the value arrayA.
- set_capstyle(cs)[source]#
Set the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- 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 for
set_linestyle
.
- set_data(t,f1,f2,*,where=None)[source]#
Set new values for the two bounding curves.
- Parameters:
- tarray-like
The
self.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 coordinates
t[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 for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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:
- sizes
numpy.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.
- sizes
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- to_rgba(x,alpha=None,bytes=False,norm=True)[source]#
Return a normalized RGBA array corresponding tox.
In the normal case,x is a 1D or 2D sequence of scalars, andthe corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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 of
Line2D
s that should be drawn together.This class extends
Collection
to represent a sequence ofLine2D
s instead of just a sequence ofPatch
s.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 thei
th elementof the collection is:prop[i%len(prop)]
The properties of each member of aLineCollection default to their valuesin
rcParams["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 use
PathCollection
instead, where the"interior" can be specified by appropriate usage ofCLOSEPOLY
.- **kwargs
Forwarded to
Collection
.
- add_callback(func)[source]#
Add a callback function that will be called whenever one of the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
unknown
bool
bool or list of bools
array-like or None
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Noneedgecolor
orec
oredgecolors
facecolor
orfacecolors
orfc
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
linestyle
ordashes
orlinestyles
orls
str or tuple or list thereof
linewidth
orlinewidths
orlw
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
list of
AbstractPathEffect
unknown
None or bool or float or callable
float
bool
unknown
(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
unknown
bool
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 class
ScalarMappable
does not make any assumptions onthe dimensionality and shape of the value arrayA.
- set_capstyle(cs)[source]#
Set the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- set_dashes(ls)[source]#
Alias for
set_linestyle
.
- set_ec(c)[source]#
Alias for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- to_rgba(x,alpha=None,bytes=False,norm=True)[source]#
Return a normalized RGBA array corresponding tox.
In the normal case,x is a 1D or 2D sequence of scalars, andthe corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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 of
Patch
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 to
Collection
.If any ofedgecolors,facecolors,linewidths,antialiasedsare None, they default to their
rcParams
patch setting, insequence form.
- patcheslist of
Notes
The use of
ScalarMappable
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 the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
array-like or float or None
bool
bool or list of bools
array-like or None
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Nonecolor or list of RGBA tuples
edgecolor
orec
oredgecolors
facecolor
orfacecolors
orfc
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
linestyle
ordashes
orlinestyles
orls
str or tuple or list thereof
linewidth
orlinewidths
orlw
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
list of
AbstractPathEffect
unknown
None or bool or float or callable
float
bool
(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
bool
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 class
ScalarMappable
does not make any assumptions onthe dimensionality and shape of the value arrayA.
- set_capstyle(cs)[source]#
Set the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- 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 for
set_linestyle
.
- set_ec(c)[source]#
Alias for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- to_rgba(x,alpha=None,bytes=False,norm=True)[source]#
Return a normalized RGBA array corresponding tox.
In the normal case,x is a 1D or 2D sequence of scalars, andthe corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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 of
Path
s, as created by e.g.scatter
.- Parameters:
- pathslist of
path.Path
The paths that will make up the
Collection
.- sizesarray-like
The factor by which to scale each drawn
Path
. One unitsquared in the Path's data space is scaled to besizes**2
points when rendered.- **kwargs
Forwarded to
Collection
.
- pathslist of
- add_callback(func)[source]#
Add a callback function that will be called whenever one of the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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 a
Line2D
representing the Path that was drawn,and each label is a string that represents the Path.This is useful for obtaining a legend for a
scatter
plot;e.g.:scatter=plt.scatter([1,2,3],[4,5,6],c=[7,2,3],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 the
Line2D
properties.- numint, None, "auto" (default), array-like, or
Locator
Target number of elements to create.If None, use all unique elements of the mappable array. If 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 a
Locator
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 a
StrMethodFormatter
. If None (the default),use aScalarFormatter
.- funcfunction, default:
lambdax:x
Function to calculate the labels. Often the size (or color)argument to
scatter
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 the
Line2D
instance. This may be useful to e.g. specify a differentmarkeredgecolor oralpha for the legend handles.
- Returns:
- handleslist of
Line2D
Visual representation of each element of the legend.
- labelslist of str
The string labels for elements of the legend.
- handleslist of
- 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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
array-like or float or None
bool
bool or list of bools
array-like or None
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Nonecolor or list of RGBA tuples
edgecolor
orec
oredgecolors
facecolor
orfacecolors
orfc
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
linestyle
ordashes
orlinestyles
orls
str or tuple or list thereof
linewidth
orlinewidths
orlw
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
list of
AbstractPathEffect
unknown
None or bool or float or callable
float
bool
numpy.ndarray
or None(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
bool
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 class
ScalarMappable
does not make any assumptions onthe dimensionality and shape of the value arrayA.
- set_capstyle(cs)[source]#
Set the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- 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 for
set_linestyle
.
- set_ec(c)[source]#
Alias for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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:
- sizes
numpy.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.
- sizes
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- to_rgba(x,alpha=None,bytes=False,norm=True)[source]#
Return a normalized RGBA array corresponding tox.
In the normal case,x is a 1D or 2D sequence of scalars, andthe corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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 to
Collection
.
- add_callback(func)[source]#
Add a callback function that will be called whenever one of the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
array-like or float or None
bool
bool or list of bools
array-like or None
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Nonecolor or list of RGBA tuples
edgecolor
orec
oredgecolors
facecolor
orfacecolors
orfc
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
linestyle
ordashes
orlinestyles
orls
str or tuple or list thereof
linewidth
orlinewidths
orlw
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
list of
AbstractPathEffect
list of array-like
None or bool or float or callable
float
bool
numpy.ndarray
or None(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
list of array-like
unknown
bool
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 class
ScalarMappable
does not make any assumptions onthe dimensionality and shape of the value arrayA.
- set_capstyle(cs)[source]#
Set the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- 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 for
set_linestyle
.
- set_ec(c)[source]#
Alias for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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:
- sizes
numpy.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.
- sizes
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- to_rgba(x,alpha=None,bytes=False,norm=True)[source]#
Return a normalized RGBA array corresponding tox.
In the normal case,x is a 1D or 2D sequence of scalars, andthe corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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
Unlike
QuadMesh
, 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 from
QuadMesh
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 to
Collection
.
- add_callback(func)[source]#
Add a callback function that will be called whenever one of the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
array-like or float or None
bool
bool or list of bools
unknown
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Nonecolor or list of RGBA tuples
edgecolor
orec
oredgecolors
facecolor
orfacecolors
orfc
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
linestyle
ordashes
orlinestyles
orls
str or tuple or list thereof
linewidth
orlinewidths
orlw
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
list of
AbstractPathEffect
list of array-like
None or bool or float or callable
float
bool
numpy.ndarray
or None(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
list of array-like
unknown
bool
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- 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 for
set_linestyle
.
- set_ec(c)[source]#
Alias for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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:
- sizes
numpy.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.
- sizes
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- to_rgba(x,alpha=None,bytes=False,norm=True)[source]#
Return a normalized RGBA array corresponding tox.
In the normal case,x is a 1D or 2D sequence of scalars, andthe corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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 other
Collection
s, 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.
- capstyle
CapStyle
-like, default: 'butt' Style to use for capping lines for all paths in the collection.Allowed values are {'butt', 'projecting', 'round'}.
- joinstyle
JoinStyle
-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_transform
Transform
, default:IdentityTransform
A single transform which will be applied to eachoffsets vectorbefore it is used.
- cmap, norm
Data normalization and colormapping parameters. See
ScalarMappable
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
If
pickradius<=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*pickradius
following any of the Paths in the Collection.- urlslist of str, default: None
A URL for each patch to link to once drawn. Currently only 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 as
Collection.set_{key}(val)
for each key-value pair inkwargs.
- edgecolorscolor or list of colors, default:
- add_callback(func)[source]#
Add a callback function that will be called whenever one of the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
array-like or float or None
bool
bool or list of bools
array-like
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Nonecolor or list of RGBA tuples
edgecolor
orec
oredgecolors
facecolor
orfacecolors
orfc
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
linestyle
ordashes
orlinestyles
orls
str or tuple or list thereof
linewidth
orlinewidths
orlw
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
list of
AbstractPathEffect
None or bool or float or callable
float
bool
(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
bool
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- 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 for
set_linestyle
.
- set_ec(c)[source]#
Alias for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- to_rgba(x,alpha=None,bytes=False,norm=True)[source]#
Return a normalized RGBA array corresponding tox.
In the normal case,x is a 1D or 2D sequence of scalars, andthe corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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 to
Collection
.
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 the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
array-like or float or None
bool
bool or list of bools
array-like or None
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Nonecolor or list of RGBA tuples
edgecolor
orec
oredgecolors
facecolor
orfacecolors
orfc
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
linestyle
ordashes
orlinestyles
orls
str or tuple or list thereof
linewidth
orlinewidths
orlw
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
list of
AbstractPathEffect
unknown
None or bool or float or callable
float
bool
numpy.ndarray
or None(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
bool
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 class
ScalarMappable
does not make any assumptions onthe dimensionality and shape of the value arrayA.
- set_capstyle(cs)[source]#
Set the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- 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 for
set_linestyle
.
- set_ec(c)[source]#
Alias for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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:
- sizes
numpy.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.
- sizes
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- to_rgba(x,alpha=None,bytes=False,norm=True)[source]#
Return a normalized RGBA array corresponding tox.
In the normal case,x is a 1D or 2D sequence of scalars, andthe corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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 to
Collection
.
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 the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
array-like or float or None
bool
bool or list of bools
array-like or None
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Nonecolor or list of RGBA tuples
edgecolor
orec
oredgecolors
facecolor
orfacecolors
orfc
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
linestyle
ordashes
orlinestyles
orls
str or tuple or list thereof
linewidth
orlinewidths
orlw
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
list of
AbstractPathEffect
unknown
None or bool or float or callable
float
bool
numpy.ndarray
or None(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
bool
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 class
ScalarMappable
does not make any assumptions onthe dimensionality and shape of the value arrayA.
- set_capstyle(cs)[source]#
Set the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- 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 for
set_linestyle
.
- set_ec(c)[source]#
Alias for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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:
- sizes
numpy.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.
- sizes
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- to_rgba(x,alpha=None,bytes=False,norm=True)[source]#
Return a normalized RGBA array corresponding tox.
In the normal case,x is a 1D or 2D sequence of scalars, andthe corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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 a
Triangulation
object.- Parameters:
- edgecolorscolor or list of colors, default:
rcParams["patch.edgecolor"]
(default:'black'
) Edge color for each patch making up the collection. The 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.
- capstyle
CapStyle
-like, default: 'butt' Style to use for capping lines for all paths in the collection.Allowed values are {'butt', 'projecting', 'round'}.
- joinstyle
JoinStyle
-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_transform
Transform
, default:IdentityTransform
A single transform which will be applied to eachoffsets vectorbefore it is used.
- cmap, norm
Data normalization and colormapping parameters. See
ScalarMappable
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
If
pickradius<=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*pickradius
following any of the Paths in the Collection.- urlslist of str, default: None
A URL for each patch to link to once drawn. Currently only 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 as
Collection.set_{key}(val)
for each key-value pair inkwargs.
- edgecolorscolor or list of colors, default:
- add_callback(func)[source]#
Add a callback function that will be called whenever one of the
Artist
's properties changes.- Parameters:
- funccallable
The callback function. It must have the signature:
deffunc(artist:Artist)->Any
whereartist is the calling
Artist
. Return values may existbut are ignored.
- Returns:
- int
The observer id associated with the callback. This id can beused for removing the callback with
remove_callback
later.
See also
- autoscale_None()[source]#
Autoscale the scalar limits on the norm instance using thecurrent array, changing only limits that are None
- 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.
Returns
bool,dict(ind=itemlist)
, where every item in itemlistcontains the event.
- staticconvert_mesh_to_paths(tri)[source]#
Convert a given mesh into a sequence of
Path
objects.This function is primarily of use to implementers of backends that 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_visible
returns False).- Parameters:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- propertyfigure#
The (Sub)Figure that the artist is on. For more control, use the
get_figure
method.
- findobj(match=None,include_self=True)[source]#
Find artist objects.
Recursively find all
Artist
instances contained in the artist.- Parameters:
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
defmatch(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 of
Artist
- list of
- 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.
See also
- get_aa()[source]#
Alias for
get_antialiased
.
- get_antialiaseds()[source]#
Alias for
get_antialiased
.
- get_array()[source]#
Return the array of values, that are mapped to colors.
The base class
ScalarMappable
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_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 that
format_cursor_data
can convertthe data to a string representation.The only current use case is displaying the z-value of an
AxesImage
in the status bar of a plot window, while moving the mouse.- Parameters:
- event
MouseEvent
- event
See also
- get_dashes()[source]#
Alias for
get_linestyle
.
- get_ec()[source]#
Alias for
get_edgecolor
.
- get_edgecolors()[source]#
Alias for
get_edgecolor
.
- get_facecolors()[source]#
Alias for
get_facecolor
.
- get_fc()[source]#
Alias for
get_facecolor
.
- get_figure(root=False)[source]#
Return the
Figure
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_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_linestyles()[source]#
Alias for
get_linestyle
.
- get_linewidths()[source]#
Alias for
get_linewidth
.
- get_ls()[source]#
Alias for
get_linestyle
.
- get_lw()[source]#
Alias for
get_linewidth
.
- get_mouseover()[source]#
Return whether this artist is queried for custom context informationwhen the mouse cursor moves over it.
- get_picker()[source]#
Return the picking behavior of the artist.
The possible values are described in
Artist.set_picker
.
- 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_tightbbox(renderer=None)[source]#
Like
Artist.get_window_extent
, but includes any clipping.- Parameters:
- renderer
RendererBase
subclass, optional renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates).Returns None if clipping results in no intersection.
- get_transOffset()[source]#
Alias for
get_offset_transform
.
- 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_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_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 call
matplotlib.figure.Figure.savefig
ormatplotlib.figure.Figure.draw_without_rendering
to have Matplotlibcompute the rendered size.
- is_transform_set()[source]#
Return whether the Artist has an explicitly set transform.
This isTrue after
set_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.
See also
- 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.
- remove()[source]#
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g.,with
FigureCanvasBase.draw_idle
. 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.
- 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
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
array-like or float or None
bool
bool or list of bools
array-like or None
CapStyle
or {'butt', 'projecting', 'round'}(vmin: float, vmax: float)
BboxBase
or Nonebool
Patch or (Path, Transform) or None
Colormap
or str or Nonecolor or list of RGBA tuples
edgecolor
orec
oredgecolors
facecolor
orfacecolors
orfc
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
bool
JoinStyle
or {'miter', 'round', 'bevel'}object
linestyle
ordashes
orlinestyles
orls
str or tuple or list thereof
linewidth
orlinewidths
orlw
float or list of floats
bool
Normalize
or str or None(N, 2) or (2,) array-like
list of
AbstractPathEffect
None or bool or float or callable
float
bool
(scale: float, length: float, randomness: float)
bool or None
str
list of str or None
bool
float
- set_aa(aa)[source]#
Alias for
set_antialiased
.
- set_agg_filter(filter_func)[source]#
Set the agg filter.
- Parameters:
- filter_funccallable
A filter function, which takes a (m, n, 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 call
Figure.draw_artist
/Axes.draw_artist
explicitly on the artist. This approach is used to speed up animationsusing blitting.See also
matplotlib.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 for
set_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 class
ScalarMappable
does not make any assumptions onthe dimensionality and shape of the value arrayA.
- set_capstyle(cs)[source]#
Set the
CapStyle
for the collection (for all its elements).- Parameters:
- cs
CapStyle
or {'butt', 'projecting', 'round'}
- cs
- 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 clip
Bbox
.- Parameters:
- clipbox
BboxBase
or None Will typically be created from a
TransformedBbox
. For instance,TransformedBbox(Bbox([[0,0],[1,1]]),ax.transAxes)
is the defaultclipping for an artist added to an Axes.
- clipbox
- 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:
- path
Patch
orPath
orTransformedPath
or None The clip path. If given a
Path
,transform must be provided aswell. IfNone, a previously set clip path is removed.- transform
Transform
, optional Only used ifpath is a
Path
, in which case the givenPath
is converted to aTransformedPath
usingtransform.
- path
Notes
For efficiency, ifpath is a
Rectangle
this method will set theclipping box to the corresponding rectangle and set the clipping pathtoNone
.For technical reasons (support of
set
), a tuple(path,transform) is also accepted as a single positionalparameter.
- 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 for
set_linestyle
.
- set_ec(c)[source]#
Alias for
set_edgecolor
.
- set_edgecolors(c)[source]#
Alias for
set_edgecolor
.
- set_facecolor(c)[source]#
Set the facecolor(s) of the collection.c can be a color (all 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.
- set_facecolors(c)[source]#
Alias for
set_facecolor
.
- set_fc(c)[source]#
Alias for
set_facecolor
.
- 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_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 the
JoinStyle
for the collection (for all its elements).- Parameters:
- js
JoinStyle
or {'miter', 'round', 'bevel'}
- js
- set_label(s)[source]#
Set a label that will be displayed in the legend.
- Parameters:
- sobject
s will be converted to a string by calling
str
.
- set_linestyle(ls)[source]#
Set the linestyle(s) for the collection.
linestyle
description
'-'
or'solid'
solid line
'--'
or'dashed'
dashed line
'-.'
or'dashdot'
dash-dotted line
':'
or'dotted'
dotted line
Alternatively a dash tuple of the following form can be provided:
(offset,onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.- Parameters:
- lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.',':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for acomplete description.
- set_linestyles(ls)[source]#
Alias for
set_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 for
set_linewidth
.
- set_ls(ls)[source]#
Alias for
set_linestyle
.
- set_lw(lw)[source]#
Alias for
set_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:
- norm
Normalize
or str or None
- norm
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_transform
Transform
- offset_transform
- 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 of
AbstractPathEffect
- path_effectslist of
- 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 is
None
, 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 for
set_offset_transform
.
- 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_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, the
x
andy
lists can be modified in place as needed.Examples
>>>artist.sticky_edges.x[:]=(xmin,xmax)>>>artist.sticky_edges.y[:]=(ymin,ymax)
- to_rgba(x,alpha=None,bytes=False,norm=True)[source]#
Return a normalized RGBA array corresponding tox.
In the normal case,x is a 1D or 2D sequence of scalars, andthe corresponding
ndarray
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 an
ndarray
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 be
uint8
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_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:
- sizes
numpy.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.
- sizes
- 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.