matplotlib.collections
#
Classes for the efficient drawing of large collections of objects that share most properties, e.g., a large number of line segments or polygons.
The classes are not meant to be as flexible as their single element counterparts (e.g., you may not be able to select all line styles) but they are meant to be fast for common use cases (e.g., a large set of solid line segments).
Bases: RegularPolyCollection
Draw a collection of regular asterisks with numsides points.
The number of sides of the polygon.
The rotation of the polygon in radians.
The area of the circle circumscribing the polygon in points^2.
Forwarded to Collection
.
Examples
See Lasso Demo for a complete example:
offsets = np.random.rand(20, 2) facecolors = [cm.jet(x) for x in np.random.rand(20)] collection = RegularPolyCollection( numsides=5, # a pentagon rotation=0, sizes=(50,), facecolors=facecolors, edgecolors=("black",), linewidths=(1,), offsets=offsets, offset_transform=ax.transData, )
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Alias for get_linestyle
.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return whether the artist is to be rasterized.
Return the sizes ('areas') of the elements in the collection.
The 'area' of each element.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the value array from array-like A.
The values that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the value array A.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor, facecolor and hatchcolor.
Changed in version 3.11: Now sets the hatchcolor as well.
Alias for set_linestyle
.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the path effects.
AbstractPathEffect
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sizes of each member of the collection.
numpy.ndarray
or None
The size to set for each element of the collection. The value is the 'area' of the element.
The dpi of the canvas.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the artist's visibility.
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
Bases: _CollectionWithSizes
A collection of circles, drawn using splines.
The area of each circle in points^2.
Forwarded to Collection
.
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Alias for get_linestyle
.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return whether the artist is to be rasterized.
Return the sizes ('areas') of the elements in the collection.
The 'area' of each element.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the value array from array-like A.
The values that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the value array A.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor, facecolor and hatchcolor.
Changed in version 3.11: Now sets the hatchcolor as well.
Alias for set_linestyle
.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the path effects.
AbstractPathEffect
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sizes of each member of the collection.
numpy.ndarray
or None
The size to set for each element of the collection. The value is the 'area' of the element.
The dpi of the canvas.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the artist's visibility.
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
Bases: ColorizingArtist
Base class for Collections. Must be subclassed to be usable.
A Collection represents a sequence of Patch
es that can be drawn more efficiently together than individually. For example, when a single path is being drawn repeatedly at different offsets, the renderer can typically execute a draw_marker()
call much more efficiently than a series of repeated calls to draw_path()
with the offsets put in one-by-one.
Most properties of a collection can be configured per-element. Therefore, Collections have "plural" versions of many of the properties of a Patch
(e.g. Collection.get_paths
instead of Patch.get_path
). Exceptions are the zorder, hatch, pickradius, capstyle and joinstyle properties, which can only be set globally for the whole collection.
Besides these exceptions, all properties can be specified as single values (applying to all elements) or sequences of values. The property of the i
th element of the collection is:
Each Collection can optionally be used as its own ScalarMappable
by passing the norm and cmap parameters to its constructor. If the Collection's ScalarMappable
matrix _A
has been set (via a call to Collection.set_array
), then at draw time this internal scalar mappable will be used to set the facecolors
and edgecolors
, ignoring those that were manually passed in.
rcParams["patch.edgecolor"]
(default: 'black'
)
Edge color for each patch making up the collection. The special value 'face' can be passed to make the edgecolor match the facecolor.
rcParams["patch.facecolor"]
(default: 'C0'
)
Face color for each patch making up the collection.
rcParams["hatch.color"]
(default: 'edge'
)
Hatch color for each patch making up the collection. The color can be set to the special value 'edge' to make the hatchcolor match the edgecolor.
rcParams["patch.linewidth"]
(default: 1.0
)
Line width for each patch making up the collection.
Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:
where onoffseq is an even length tuple of on and off ink lengths in points. For examples, see Linestyles.
CapStyle
-like, default: 'butt'
Style to use for capping lines for all paths in the collection. Allowed values are {'butt', 'projecting', 'round'}.
JoinStyle
-like, default: 'round'
Style to use for joining lines for all paths in the collection. Allowed values are {'miter', 'round', 'bevel'}.
rcParams["patch.antialiased"]
(default: True
)
Whether each patch in the collection should be drawn with antialiasing.
A vector by which to translate each patch after rendering (default is no translation). The translation is performed in screen (pixel) coordinates (i.e. after the Artist's transform is applied).
Transform
, default: IdentityTransform
A single transform which will be applied to each offsets vector before it is used.
Data normalization and colormapping parameters. See ScalarMappable
for a detailed description.
Hatching pattern to use in filled paths, if any. Valid strings are ['/', '', '|', '-', '+', 'x', 'o', 'O', '.', '*']. See Hatch style reference for the meaning of each hatch type.
If pickradius <= 0
, then Collection.contains
will return True
whenever the test point is inside of one of the polygons formed by the control points of a Path in the Collection. On the other hand, if it is greater than 0, then we instead check if the test point is contained in a stroke of width 2*pickradius
following any of the Paths in the Collection.
A URL for each patch to link to once drawn. Currently only works for the SVG backend. See Hyperlinks for examples.
The drawing order, shared by all Patches in the Collection. See Zorder Demo for all defaults and examples.
Remaining keyword arguments will be used to set properties as Collection.set_{key}(val)
for each key-value pair in kwargs.
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Alias for get_linestyle
.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return whether the artist is to be rasterized.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the value array from array-like A.
The values that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the value array A.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor, facecolor and hatchcolor.
Changed in version 3.11: Now sets the hatchcolor as well.
Alias for set_linestyle
.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the path effects.
AbstractPathEffect
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the artist's visibility.
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
Bases: Collection
A collection of ellipses, drawn using splines.
The lengths of the first axes (e.g., major axis lengths).
The lengths of second axes.
The angles of the first axes, degrees CCW from the x-axis.
The units in which majors and minors are given; 'width' and 'height' refer to the dimensions of the axes, while 'x' and 'y' refer to the offsets data units. 'xy' differs from all others in that the angle as plotted varies with the aspect ratio, and equals the specified angle only when the aspect ratio is unity. Hence it behaves the same as the Ellipse
with axes.transData
as its transform.
Forwarded to Collection
.
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Get the angles of the first axes, degrees CCW from the x-axis.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Set the lengths of second axes (e.g., minor axes).
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Alias for get_linestyle
.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return whether the artist is to be rasterized.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the lengths of the first axes (e.g., major axis).
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
Set the angles of the first axes, degrees CCW from the x-axis.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the value array from array-like A.
The values that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the value array A.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor, facecolor and hatchcolor.
Changed in version 3.11: Now sets the hatchcolor as well.
Alias for set_linestyle
.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set the lengths of second axes (e.g., minor axes).
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the path effects.
AbstractPathEffect
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the artist's visibility.
Set the lengths of the first axes (e.g., major axis).
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
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 an amplitude and are displayed as parallel lines.
Each value is an event.
The sequence of events is plotted along this direction. The marker lines of the single events are along the orthogonal direction.
The offset of the center of the markers from the origin, in the direction orthogonal to orientation.
The total height of the marker (i.e. the marker stretches from lineoffset - linelength/2
to lineoffset + linelength/2
).
rcParams["lines.linewidth"]
(default: 1.5
)
The line width of the event lines, in points.
rcParams["lines.color"]
(default: 'C0'
)
The color of the event lines.
Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:
where onoffseq is an even length tuple of on and off ink in points.
rcParams["lines.antialiased"]
(default: True
)
Whether to use antialiasing for drawing the lines.
Forwarded to LineCollection
.
Examples
(Source code
, 2x.png
, png
)
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Add one or more events at the specified positions.
Add one or more events at the specified positions.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
Add one or more events at the specified positions.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the color of the lines used to mark each event.
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Return the length of the lines used to mark each event.
Return the offset of the lines used to mark each event.
Alias for get_linestyle
.
Get the width of the lines used to mark each event.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the orientation of the event line ('horizontal' or 'vertical').
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return an array containing the floating-point values of the positions.
Return whether the artist is to be rasterized.
List of segments in the LineCollection. Each list item contains an array of vertices.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
True if the eventcollection is horizontal, False if vertical.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the value array from array-like A.
The values that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the value array A.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor(s) of the LineCollection.
Single color (all lines have same color), or a sequence of RGBA tuples; if it is a sequence the lines will cycle through the sequence.
Set the edgecolor(s) of the LineCollection.
Single color (all lines have same color), or a sequence of RGBA tuples; if it is a sequence the lines will cycle through the sequence.
Alias for set_linestyle
.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
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 in artifacts when using transparency.
This functionality is experimental and may change.
The color with which to fill the gaps. If None, the gaps are unfilled.
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the length of the lines used to mark each event.
Set the offset of the lines used to mark each event.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the orientation of the event line.
Set the path effects.
AbstractPathEffect
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Set the positions of the events.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the artist's visibility.
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Switch the orientation of the event line, either from vertical to horizontal or vice versus.
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
Bases: PolyCollection
PolyCollection
that fills the area between two x- or y-curves.
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)
.
The t_direction
coordinates of the nodes defining the curves.
The other coordinates of the nodes defining the first curve.
The other coordinates of the nodes defining the second curve.
Define where to exclude some {dir} regions from being filled. The filled regions are defined by the coordinates t[where]
. More precisely, fill between t[i]
and t[i+1]
if where[i] and where[i+1]
. Note that this definition implies that an isolated True value between two False values in where will not result in filling. Both sides of the True position remain unfilled due to the adjacent False values.
This option is only relevant if where is used and the two curves are crossing each other.
Semantically, where is often used for f1 > f2 or similar. By default, the nodes of the polygon defining the filled region will only be placed at the positions in the t array. Such a polygon cannot describe the above semantics close to the intersection. The t-sections containing the intersection are simply clipped.
Setting interpolate to True will calculate the actual intersection point and extend the filled region up to this point.
Define step if the filling should be a step function, i.e. constant in between t. The value determines where the step will occur:
'pre': The f value is continued constantly to the left from every t position, i.e. the interval (t[i-1], t[i]]
has the value f[i]
.
'post': The y value is continued constantly to the right from every x position, i.e. the interval [t[i], t[i+1])
has the value f[i]
.
'mid': Steps occur half-way between the t positions.
Forwarded to PolyCollection
.
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Calculate the data limits and return them as a Bbox
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Alias for get_linestyle
.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return whether the artist is to be rasterized.
Return the sizes ('areas') of the elements in the collection.
The 'area' of each element.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the value array from array-like A.
The values that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the value array A.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor, facecolor and hatchcolor.
Changed in version 3.11: Now sets the hatchcolor as well.
Alias for set_linestyle
.
Set new values for the two bounding curves.
The self.t_direction
coordinates of the nodes defining the curves.
The other coordinates of the nodes defining the first curve.
The other coordinates of the nodes defining the second curve.
Define where to exclude some {dir} regions from being filled. The filled regions are defined by the coordinates t[where]
. More precisely, fill between t[i]
and t[i+1]
if where[i] and where[i+1]
. Note that this definition implies that an isolated True value between two False values in where will not result in filling. Both sides of the True position remain unfilled due to the adjacent False values.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the path effects.
AbstractPathEffect
Set the vertices of the polygons.
The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).
Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sizes of each member of the collection.
numpy.ndarray
or None
The size to set for each element of the collection. The value is the 'area' of the element.
The dpi of the canvas.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the vertices of the polygons.
The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).
Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.
Initialize vertices with path codes.
Set the artist's visibility.
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
Bases: Collection
Represents a sequence of Line2D
s that should be drawn together.
This class extends Collection
to represent a sequence of Line2D
s instead of just a sequence of Patch
s. Just as in Collection
, each property of a LineCollection may be either a single value or a list of values. This list is then used cyclically for each element of the LineCollection, so the property of the i
th element of the collection is:
The properties of each member of a LineCollection default to their values in rcParams["lines.*"]
instead of rcParams["patch.*"]
, and the property colors is added in place of edgecolors.
A sequence [line0, line1, ...]
where each line is a (N, 2)-shape array-like containing points:
line0 = [(x0, y0), (x1, y1), ...]
Each line can contain a different number of points.
rcParams["lines.linewidth"]
(default: 1.5
)
The width of each line in points.
rcParams["lines.color"]
(default: 'C0'
)
A sequence of RGBA tuples (e.g., arbitrary color strings, etc, not allowed).
rcParams["lines.antialiased"]
(default: True
)
Whether to use antialiasing for each line.
zorder of the lines once drawn.
When setting facecolors, each line is interpreted as a boundary for an area, implicitly closing the path from the last point to the first point. The enclosed area is filled with facecolor. In order to manually specify what should count as the "interior" of each line, please use PathCollection
instead, where the "interior" can be specified by appropriate usage of CLOSEPOLY
.
Forwarded to Collection
.
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Alias for get_linestyle
.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return whether the artist is to be rasterized.
List of segments in the LineCollection. Each list item contains an array of vertices.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the value array from array-like A.
The values that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the value array A.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor(s) of the LineCollection.
Single color (all lines have same color), or a sequence of RGBA tuples; if it is a sequence the lines will cycle through the sequence.
Set the edgecolor(s) of the LineCollection.
Single color (all lines have same color), or a sequence of RGBA tuples; if it is a sequence the lines will cycle through the sequence.
Alias for set_linestyle
.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
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 in artifacts when using transparency.
This functionality is experimental and may change.
The color with which to fill the gaps. If None, the gaps are unfilled.
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the path effects.
AbstractPathEffect
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the artist's visibility.
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
Bases: Collection
A generic collection of patches.
PatchCollection draws faster than a large number of equivalent individual Patches. It also makes it easier to assign a colormap to a heterogeneous collection of patches.
Patch
A sequence of Patch objects. This list may include a heterogeneous assortment of different patch types.
If True, use the colors and linewidths of the original patches. If False, new colors may be assigned by providing the standard collection arguments, facecolor, edgecolor, linewidths, norm or cmap.
All other parameters are forwarded to Collection
.
If any of edgecolors, facecolors, linewidths, antialiaseds are None, they default to their rcParams
patch setting, in sequence form.
Notes
The use of ScalarMappable
functionality is optional. If the ScalarMappable
matrix _A
has been set (via a call to set_array
), at draw time a call to scalar mappable will be made to set the face colors.
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Alias for get_linestyle
.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return whether the artist is to be rasterized.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the value array from array-like A.
The values that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the value array A.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor, facecolor and hatchcolor.
Changed in version 3.11: Now sets the hatchcolor as well.
Alias for set_linestyle
.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the path effects.
AbstractPathEffect
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the artist's visibility.
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
Bases: _CollectionWithSizes
A collection of Path
s, as created by e.g. scatter
.
path.Path
The paths that will make up the Collection
.
The factor by which to scale each drawn Path
. One unit squared in the Path's data space is scaled to be sizes**2
points when rendered.
Forwarded to Collection
.
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Alias for get_linestyle
.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return whether the artist is to be rasterized.
Return the sizes ('areas') of the elements in the collection.
The 'area' of each element.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
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 numerical values passed to c as the labels.
Also see the Automated legend creation example.
If "colors", the legend handles will show the different colors of the collection. If "sizes", the legend will show the different sizes. To set both, use kwargs to directly edit the Line2D
properties.
Locator
Target number of elements to create. If None, use all unique elements of the mappable array. If an integer, target to use num elements in the normed range. If "auto", try to determine which option better suits the nature of the data. The number of created elements may slightly deviate from num due to a Locator
being used to find useful locations. If a list or array, use exactly those elements for the legend. Finally, a Locator
can be provided.
Formatter
, or None (default)
The format or formatter to use for the labels. If a string must be a valid input for a StrMethodFormatter
. If None (the default), use a ScalarFormatter
.
lambda x: x
Function to calculate the labels. Often the size (or color) argument to scatter
will have been pre-processed by the user using a function s = f(x)
to make the markers visible; e.g. size = np.log10(x)
. Providing the inverse of this function here allows that pre-processing to be inverted, so that the legend labels have the correct values; e.g. func = lambda x: 10**x
.
Allowed keyword arguments are color and size. E.g. it may be useful to set the color of the markers if prop="sizes" is used; similarly to set the size of the markers if prop="colors" is used. Any further parameters are passed onto the Line2D
instance. This may be useful to e.g. specify a different markeredgecolor or alpha for the legend handles.
Line2D
Visual representation of each element of the legend.
The string labels for elements of the legend.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the value array from array-like A.
The values that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the value array A.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor, facecolor and hatchcolor.
Changed in version 3.11: Now sets the hatchcolor as well.
Alias for set_linestyle
.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the path effects.
AbstractPathEffect
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sizes of each member of the collection.
numpy.ndarray
or None
The size to set for each element of the collection. The value is the 'area' of the element.
The dpi of the canvas.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the artist's visibility.
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
Bases: _CollectionWithSizes
The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).
Squared scaling factors for the polygons. The coordinates of each polygon verts_i are multiplied by the square-root of the corresponding entry in sizes (i.e., sizes specify the scaling of areas). The scaling is applied before the Artist master transform.
Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.
Forwarded to Collection
.
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Alias for get_linestyle
.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return whether the artist is to be rasterized.
Return the sizes ('areas') of the elements in the collection.
The 'area' of each element.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the value array from array-like A.
The values that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the value array A.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor, facecolor and hatchcolor.
Changed in version 3.11: Now sets the hatchcolor as well.
Alias for set_linestyle
.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the path effects.
AbstractPathEffect
Set the vertices of the polygons.
The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).
Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sizes of each member of the collection.
numpy.ndarray
or None
The size to set for each element of the collection. The value is the 'area' of the element.
The dpi of the canvas.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the vertices of the polygons.
The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).
Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.
Initialize vertices with path codes.
Set the artist's visibility.
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
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 are defined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) is defined by the vertices
(m+1, n) ----------- (m+1, n+1) / / / / / / (m, n) -------- (m, n+1)
The mesh need not be regular and the polygons need not be convex.
The vertices. coordinates[m, n]
specifies the (x, y) coordinates of 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 wanting to add additional properties to the cells, such as hatching.
Another difference from QuadMesh
is that if any of the vertices or data of a cell are masked, that Polygon will not be drawn and it won't be in the list of paths returned.
The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).
Squared scaling factors for the polygons. The coordinates of each polygon verts_i are multiplied by the square-root of the corresponding entry in sizes (i.e., sizes specify the scaling of areas). The scaling is applied before the Artist master transform.
Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.
Forwarded to Collection
.
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the vertices of the mesh as an (M+1, N+1, 2) array.
M, N are the number of quadrilaterals in the rows / columns of the mesh, corresponding to (M+1, N+1) vertices. The last dimension specifies the components (x, y).
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Alias for get_linestyle
.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return whether the artist is to be rasterized.
Return the sizes ('areas') of the elements in the collection.
The 'area' of each element.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the data values.
The mesh data. Supported array shapes are:
(M, N) or (M*N,): a mesh with scalar data. The values are mapped to colors using normalization and a colormap. See parameters norm, 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 the coordinates grid. If the values are 1D, they are reshaped to 2D. M, N follow from the coordinates grid, where the coordinates grid shape is (M, N) for 'gouraud' shading and (M+1, N+1) for 'flat' shading.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor, facecolor and hatchcolor.
Changed in version 3.11: Now sets the hatchcolor as well.
Alias for set_linestyle
.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the path effects.
AbstractPathEffect
Set the vertices of the polygons.
The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).
Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sizes of each member of the collection.
numpy.ndarray
or None
The size to set for each element of the collection. The value is the 'area' of the element.
The dpi of the canvas.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the vertices of the polygons.
The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).
Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.
Initialize vertices with path codes.
Set the artist's visibility.
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
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 are defined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) is defined by the vertices
(m+1, n) ----------- (m+1, n+1) / / / / / / (m, n) -------- (m, n+1)
The mesh need not be regular and the polygons need not be convex.
The vertices. coordinates[m, n]
specifies the (x, y) coordinates of vertex (m, n).
Notes
Unlike other Collection
s, the default pickradius of QuadMesh
is 0, i.e. contains
checks whether the test point is within any of the mesh quadrilaterals.
rcParams["patch.edgecolor"]
(default: 'black'
)
Edge color for each patch making up the collection. The special value 'face' can be passed to make the edgecolor match the facecolor.
rcParams["patch.facecolor"]
(default: 'C0'
)
Face color for each patch making up the collection.
rcParams["hatch.color"]
(default: 'edge'
)
Hatch color for each patch making up the collection. The color can be set to the special value 'edge' to make the hatchcolor match the edgecolor.
rcParams["patch.linewidth"]
(default: 1.0
)
Line width for each patch making up the collection.
Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:
where onoffseq is an even length tuple of on and off ink lengths in points. For examples, see Linestyles.
CapStyle
-like, default: 'butt'
Style to use for capping lines for all paths in the collection. Allowed values are {'butt', 'projecting', 'round'}.
JoinStyle
-like, default: 'round'
Style to use for joining lines for all paths in the collection. Allowed values are {'miter', 'round', 'bevel'}.
rcParams["patch.antialiased"]
(default: True
)
Whether each patch in the collection should be drawn with antialiasing.
A vector by which to translate each patch after rendering (default is no translation). The translation is performed in screen (pixel) coordinates (i.e. after the Artist's transform is applied).
Transform
, default: IdentityTransform
A single transform which will be applied to each offsets vector before it is used.
Data normalization and colormapping parameters. See ScalarMappable
for a detailed description.
Hatching pattern to use in filled paths, if any. Valid strings are ['/', '', '|', '-', '+', 'x', 'o', 'O', '.', '*']. See Hatch style reference for the meaning of each hatch type.
If pickradius <= 0
, then Collection.contains
will return True
whenever the test point is inside of one of the polygons formed by the control points of a Path in the Collection. On the other hand, if it is greater than 0, then we instead check if the test point is contained in a stroke of width 2*pickradius
following any of the Paths in the Collection.
A URL for each patch to link to once drawn. Currently only works for the SVG backend. See Hyperlinks for examples.
The drawing order, shared by all Patches in the Collection. See Zorder Demo for all defaults and examples.
Remaining keyword arguments will be used to set properties as Collection.set_{key}(val)
for each key-value pair in kwargs.
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the vertices of the mesh as an (M+1, N+1, 2) array.
M, N are the number of quadrilaterals in the rows / columns of the mesh, corresponding to (M+1, N+1) vertices. The last dimension specifies the components (x, y).
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Alias for get_linestyle
.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return whether the artist is to be rasterized.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the data values.
The mesh data. Supported array shapes are:
(M, N) or (M*N,): a mesh with scalar data. The values are mapped to colors using normalization and a colormap. See parameters norm, 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 the coordinates grid. If the values are 1D, they are reshaped to 2D. M, N follow from the coordinates grid, where the coordinates grid shape is (M, N) for 'gouraud' shading and (M+1, N+1) for 'flat' shading.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor, facecolor and hatchcolor.
Changed in version 3.11: Now sets the hatchcolor as well.
Alias for set_linestyle
.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the path effects.
AbstractPathEffect
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the artist's visibility.
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
Bases: _CollectionWithSizes
A collection of n-sided regular polygons.
The number of sides of the polygon.
The rotation of the polygon in radians.
The area of the circle circumscribing the polygon in points^2.
Forwarded to Collection
.
Examples
See Lasso Demo for a complete example:
offsets = np.random.rand(20, 2) facecolors = [cm.jet(x) for x in np.random.rand(20)] collection = RegularPolyCollection( numsides=5, # a pentagon rotation=0, sizes=(50,), facecolors=facecolors, edgecolors=("black",), linewidths=(1,), offsets=offsets, offset_transform=ax.transData, )
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Alias for get_linestyle
.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return whether the artist is to be rasterized.
Return the sizes ('areas') of the elements in the collection.
The 'area' of each element.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the value array from array-like A.
The values that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the value array A.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor, facecolor and hatchcolor.
Changed in version 3.11: Now sets the hatchcolor as well.
Alias for set_linestyle
.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the path effects.
AbstractPathEffect
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sizes of each member of the collection.
numpy.ndarray
or None
The size to set for each element of the collection. The value is the 'area' of the element.
The dpi of the canvas.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the artist's visibility.
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
Bases: RegularPolyCollection
Draw a collection of regular stars with numsides points.
The number of sides of the polygon.
The rotation of the polygon in radians.
The area of the circle circumscribing the polygon in points^2.
Forwarded to Collection
.
Examples
See Lasso Demo for a complete example:
offsets = np.random.rand(20, 2) facecolors = [cm.jet(x) for x in np.random.rand(20)] collection = RegularPolyCollection( numsides=5, # a pentagon rotation=0, sizes=(50,), facecolors=facecolors, edgecolors=("black",), linewidths=(1,), offsets=offsets, offset_transform=ax.transData, )
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Alias for get_linestyle
.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return whether the artist is to be rasterized.
Return the sizes ('areas') of the elements in the collection.
The 'area' of each element.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the value array from array-like A.
The values that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the value array A.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor, facecolor and hatchcolor.
Changed in version 3.11: Now sets the hatchcolor as well.
Alias for set_linestyle
.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the path effects.
AbstractPathEffect
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sizes of each member of the collection.
numpy.ndarray
or None
The size to set for each element of the collection. The value is the 'area' of the element.
The dpi of the canvas.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the artist's visibility.
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
Bases: Collection
Class for the efficient drawing of a triangular mesh using Gouraud shading.
A triangular mesh is a Triangulation
object.
rcParams["patch.edgecolor"]
(default: 'black'
)
Edge color for each patch making up the collection. The special value 'face' can be passed to make the edgecolor match the facecolor.
rcParams["patch.facecolor"]
(default: 'C0'
)
Face color for each patch making up the collection.
rcParams["hatch.color"]
(default: 'edge'
)
Hatch color for each patch making up the collection. The color can be set to the special value 'edge' to make the hatchcolor match the edgecolor.
rcParams["patch.linewidth"]
(default: 1.0
)
Line width for each patch making up the collection.
Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:
where onoffseq is an even length tuple of on and off ink lengths in points. For examples, see Linestyles.
CapStyle
-like, default: 'butt'
Style to use for capping lines for all paths in the collection. Allowed values are {'butt', 'projecting', 'round'}.
JoinStyle
-like, default: 'round'
Style to use for joining lines for all paths in the collection. Allowed values are {'miter', 'round', 'bevel'}.
rcParams["patch.antialiased"]
(default: True
)
Whether each patch in the collection should be drawn with antialiasing.
A vector by which to translate each patch after rendering (default is no translation). The translation is performed in screen (pixel) coordinates (i.e. after the Artist's transform is applied).
Transform
, default: IdentityTransform
A single transform which will be applied to each offsets vector before it is used.
Data normalization and colormapping parameters. See ScalarMappable
for a detailed description.
Hatching pattern to use in filled paths, if any. Valid strings are ['/', '', '|', '-', '+', 'x', 'o', 'O', '.', '*']. See Hatch style reference for the meaning of each hatch type.
If pickradius <= 0
, then Collection.contains
will return True
whenever the test point is inside of one of the polygons formed by the control points of a Path in the Collection. On the other hand, if it is greater than 0, then we instead check if the test point is contained in a stroke of width 2*pickradius
following any of the Paths in the Collection.
A URL for each patch to link to once drawn. Currently only works for the SVG backend. See Hyperlinks for examples.
The drawing order, shared by all Patches in the Collection. See Zorder Demo for all defaults and examples.
Remaining keyword arguments will be used to set properties as Collection.set_{key}(val)
for each key-value pair in kwargs.
Add a callback function that will be called whenever one of the Artist
's properties changes.
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling Artist
. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback
later.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
The Axes
instance the artist resides in, or None.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
The last colorbar associated with this object. May be None
Test whether the mouse event occurred in the collection.
Returns bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
Convert a given mesh into a sequence of Path
objects.
This function is primarily of use to implementers of backends that do not directly support meshes.
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
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).
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
The (Sub)Figure that the artist is on. For more control, use the get_figure
method.
Find artist objects.
Recursively find all Artist
instances contained in the artist.
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.
A class instance: e.g., Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
Include self in the list to be checked for a match.
Artist
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
Alias for get_antialiased
.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Get the antialiasing state for rendering.
Alias for get_antialiased
.
Return the array of values, that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the array.
Return the cap style for the collection (for all its elements).
Return the values (min, max) that are mapped to the colormap limits.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the Colormap
instance.
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data
can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage
in the status bar of a plot window, while moving the mouse.
MouseEvent
Alias for get_linestyle
.
Alias for get_edgecolor
.
Alias for get_edgecolor
.
Alias for get_facecolor
.
Alias for get_facecolor
.
Return the Figure
or SubFigure
instance the artist belongs to.
If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.
Return whether face is colored.
Return the group id.
Return the current hatching pattern.
Return the hatch linewidth.
Return boolean flag, True
if artist is included in layout calculations.
E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Return the join style for the collection (for all its elements).
Return the label used for this artist in the legend.
Alias for get_linestyle
.
Alias for get_linewidth
.
Alias for get_linestyle
.
Alias for get_linewidth
.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the Transform
instance used by this artist offset.
Return the offsets for the collection.
Return the picking behavior of the artist.
The possible values are described in Artist.set_picker
.
Return whether the artist is to be rasterized.
Return the sketch parameters for the artist.
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
Return the snap setting.
See set_snap
for details.
Get the artist's bounding box in display space, taking clipping into account.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Bbox
or None
The enclosing bounding box (in figure pixel coordinates), or None if clipping results in no intersection.
Alias for get_offset_transform
.
Return the Transform
instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
Return the url.
Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
Return the visibility.
Get the artist's bounding box in display space, ignoring clipping.
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 bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call savefig
or draw_without_rendering
to have Matplotlib compute the rendered size.
RendererBase
, optional
Renderer used to draw the figure (i.e. fig.canvas.get_renderer()
).
Return the artist's zorder.
Return whether units are set on any axis.
Return whether the Artist has an explicitly set transform.
This is True after set_transform
has been called.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle
. Call relim
to update the Axes limits if desired.
Note: relim
will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Remove a callback based on its observer id.
Set multiple properties at once.
Supported properties are
Alias for set_antialiased
.
Set the agg filter.
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
Set the alpha value used for blending - not supported on all backends.
All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.
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 animations using blitting.
See also matplotlib.animation
and Faster rendering by using blitting.
Set the antialiasing state for rendering.
Alias for set_antialiased
.
Set the value array from array-like A.
The values that are mapped to colors.
The base class ScalarMappable
does not make any assumptions on the dimensionality and shape of the value array A.
Set the CapStyle
for the collection (for all its elements).
CapStyle
or {'butt', 'projecting', 'round'}
Set the norm limits for image scaling.
The limits.
For scalar data, the limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
Set the artist's clip Bbox
.
BboxBase
or None
Will typically be created from a TransformedBbox
. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
Set the artist's clip path.
Patch
or Path
or TransformedPath
or None
The clip path. If given a Path
, transform must be provided as well. If None, a previously set clip path is removed.
Transform
, optional
Only used if path is a Path
, in which case the given Path
is converted to a TransformedPath
using transform.
Notes
For efficiency, if path is a Rectangle
this method will set the clipping box to the corresponding rectangle and set the clipping path to None
.
For technical reasons (support of set
), a tuple (path, transform) is also accepted as a single positional parameter.
Set the colormap for luminance data.
Colormap
or str or None
Set the edgecolor, facecolor and hatchcolor.
Changed in version 3.11: Now sets the hatchcolor as well.
Alias for set_linestyle
.
Alias for set_edgecolor
.
Set the edgecolor(s) of the collection.
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
Alias for set_edgecolor
.
Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Alias for set_facecolor
.
Alias for set_facecolor
.
Set the Figure
or SubFigure
instance the artist belongs to.
Figure
or SubFigure
Set the (group) id for the artist.
Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Set the hatch linewidth.
Set the hatchcolor(s) of the collection.
The collection hatchcolor(s). If a sequence, the patches cycle through it.
Set if artist is to be included in layout calculations, E.g. Constrained layout guide, Figure.tight_layout()
, and fig.savefig(fname, bbox_inches='tight')
.
Set the JoinStyle
for the collection (for all its elements).
JoinStyle
or {'miter', 'round', 'bevel'}
Set a label that will be displayed in the legend.
s will be converted to a string by calling str
.
Set the linestyle(s) for the collection.
Alternatively a dash tuple of the following form can be provided:
where onoffseq
is an even length tuple of on and off ink in points.
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See Line2D.set_linestyle
for a complete description.
Alias for set_linestyle
.
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Alias for set_linewidth
.
Alias for set_linestyle
.
Alias for set_linewidth
.
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Set the normalization instance.
Normalize
or str or None
Notes
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Set the artist offset transform.
Transform
Set the offsets for the collection.
Set the path effects.
AbstractPathEffect
Define the picking behavior of the artist.
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
Set the pick radius used for containment tests.
Pick radius, in points.
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also Rasterization for vector graphics.
Set the sketch parameters.
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None
, or not provided, no sketch filter will be provided.
The length of the wiggle along the line, in pixels (default 128.0)
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
Alias for set_offset_transform
.
Set the artist transform.
Transform
Set the url for the artist.
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
Set the artist's visibility.
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
x
and y
sticky edge lists for autoscaling.
When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added--the view limit "sticks" to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion "bumps" against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the x
and y
lists can be modified in place as needed.
Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
Return a normalized RGBA array corresponding to x.
In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray
of RGBA values will be returned, based on the norm and colormap set for this Colorizer.
There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ndarray
with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an RGB or RGBA array, and no mapping will be done. The array can be uint8
, or it can be floats with values 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, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be uint8
in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
Update this artist's properties from the dict props.
Copy properties from other to self.
Update colors from the scalar mappable array, if any.
Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
Base class for collections that have an array of sizes.
Return the sizes ('areas') of the elements in the collection.
The 'area' of each element.
Set the sizes of each member of the collection.
numpy.ndarray
or None
The size to set for each element of the collection. The value is the 'area' of the element.
The dpi of the canvas.
Class for managing the two dimensional coordinates of Quadrilateral meshes and the associated data with them. This class is a mixin and is intended to be used with another collection that will implement the draw separately.
A quadrilateral mesh is a grid of M by N adjacent quadrilaterals that are defined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) is defined by the vertices
(m+1, n) ----------- (m+1, n+1) / / / / / / (m, n) -------- (m, n+1)
The mesh need not be regular and the polygons need not be convex.
The vertices. coordinates[m, n]
specifies the (x, y) coordinates of vertex (m, n).
Set the data values.
The mesh data. Supported array shapes are:
(M, N) or (M*N,): a mesh with scalar data. The values are mapped to colors using normalization and a colormap. See parameters norm, 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 the coordinates grid. If the values are 1D, they are reshaped to 2D. M, N follow from the coordinates grid, where the coordinates grid shape is (M, N) for 'gouraud' shading and (M+1, N+1) for 'flat' shading.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4