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).
-
class
matplotlib.collections.
AsteriskPolygonCollection
(numsides, rotation=0, sizes=(1), **kwargs)[source]¶ Bases:
matplotlib.collections.RegularPolyCollection
Draw a collection of regular asterisks with numsides points.
Parameters: - numsidesint
The number of sides of the polygon.
- rotationfloat
The rotation of the polygon in radians.
- sizestuple of float
The area of the circle circumscribing the polygon in points^2.
- **kwargs
Forwarded to
Collection
.
Examples
See Lasso Demo for a complete example:
offsets = np.random.rand(20, 2) facecolors = [cm.jet(x) for x in np.random.rand(20)] collection = RegularPolyCollection( numsides=5, # a pentagon rotation=0, sizes=(50,), facecolors=facecolors, edgecolors=("black",), linewidths=(1,), offsets=offsets, transOffset=ax.transData, )
-
add_callback
(func)¶ Add a callback function that will be called whenever one of the
Artist
's properties changes.Parameters: - funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling
Artist
. Return values may exist but are ignored.
Returns: - int
The observer id associated with the callback. This id can be used for removing the callback with
remove_callback
later.
See also
-
add_checker
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
autoscale
()¶ Autoscale the scalar limits on the norm instance using the current array
-
autoscale_None
()¶ Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
-
changed
()¶ Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
-
check_update
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
contains
(mouseevent)¶ Test whether the mouse event occurred in the collection.
Returns
bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
-
convert_xunits
(x)¶ Convert x using the unit type of the xaxis.
If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.
-
convert_yunits
(y)¶ Convert y using the unit type of the yaxis.
If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.
-
draw
(renderer)¶ Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visible
returns False).Parameters: - renderer
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
- renderer
-
findobj
(match=None, include_self=True)¶ Find artist objects.
Recursively find all
Artist
instances contained in the artist.Parameters: - match
A filter criterion for the matches. This can be
- None: Return all objects contained in artist.
- A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True. - A class instance: e.g.,
Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
- include_selfbool
Include self in the list to be checked for a match.
Returns: - list of
Artist
-
format_cursor_data
(data)¶ 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.
See also
-
get_agg_filter
()¶ Return filter function to be used for agg filter.
-
get_alpha
()¶ Return the alpha value used for blending - not supported on all backends.
-
get_animated
()¶ Return whether the artist is animated.
-
get_array
()¶ Return the data array.
-
get_capstyle
()¶
-
get_clim
()¶ Return the values (min, max) that are mapped to the colormap limits.
-
get_clip_box
()¶ Return the clipbox.
-
get_clip_on
()¶ Return whether the artist uses clipping.
-
get_clip_path
()¶ Return the clip path.
-
get_contains
()¶ [Deprecated] Return the custom contains function of the artist if set, or None.
See also
Notes
Deprecated since version 3.3.
-
get_cursor_data
(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.Parameters: See also
-
get_dashes
()¶ Alias for
get_linestyle
.
-
get_datalim
(transData)¶
-
get_ec
()¶ Alias for
get_edgecolor
.
-
get_edgecolor
()¶
-
get_edgecolors
()¶ Alias for
get_edgecolor
.
-
get_facecolor
()¶
-
get_facecolors
()¶ Alias for
get_facecolor
.
-
get_fc
()¶ Alias for
get_facecolor
.
-
get_fill
()¶ Return whether fill is set.
-
get_gid
()¶ Return the group id.
-
get_hatch
()¶ Return the current hatching pattern.
-
get_in_layout
()¶ Return boolean flag,
True
if artist is included in layout calculations.E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.
-
get_joinstyle
()¶
-
get_label
()¶ Return the label used for this artist in the legend.
-
get_linestyle
()¶
-
get_linestyles
()¶ Alias for
get_linestyle
.
-
get_linewidth
()¶
-
get_linewidths
()¶ Alias for
get_linewidth
.
-
get_ls
()¶ Alias for
get_linestyle
.
-
get_lw
()¶ Alias for
get_linewidth
.
-
get_numsides
()¶
-
get_offset_position
()¶ [Deprecated] Return how offsets are applied for the collection. If offset_position is 'screen', the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Notes
Deprecated since version 3.3.
-
get_offset_transform
()¶
-
get_offsets
()¶ Return the offsets for the collection.
-
get_path_effects
()¶
-
get_paths
()¶
-
get_picker
()¶ Return the picking behavior of the artist.
The possible values are described in
set_picker
.See also
-
get_pickradius
()¶
-
get_rasterized
()¶ Return whether the artist is to be rasterized.
-
get_rotation
()¶
-
get_sizes
()¶ Return the sizes ('areas') of the elements in the collection.
Returns: - array
The 'area' of each element.
-
get_sketch_params
()¶ Return the sketch parameters for the artist.
Returns: - tuple or None
A 3-tuple with the following elements:
- scale: The amplitude of the wiggle perpendicular to the source line.
- length: The length of the wiggle along the line.
- randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
-
get_tightbbox
(renderer)¶ Like
Artist.get_window_extent
, but includes any clipping.Parameters: - renderer
RendererBase
subclass renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
Returns: Bbox
The enclosing bounding box (in figure pixel coordinates).
- renderer
-
get_transformed_clip_path_and_affine
()¶ Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
-
get_transforms
()¶
-
get_url
()¶ Return the url.
-
get_urls
()¶ Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
-
get_visible
()¶ Return the visibility.
-
get_window_extent
(renderer)¶ Get the axes bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
-
get_zorder
()¶ Return the artist's zorder.
-
have_units
()¶ Return True if units are set on any axis.
-
is_transform_set
()¶ Return whether the Artist has an explicitly set transform.
This is True after
set_transform
has been called.
-
property
mouseover
¶ If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also
get_cursor_data()
,ToolCursorPosition
andNavigationToolbar2
.
-
pchanged
()¶ Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
-
pick
(mouseevent)¶ Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
-
pickable
()¶ Return whether the artist is pickable.
See also
-
properties
()¶ Return a dictionary of all the properties of the artist.
-
remove
()¶ Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with
FigureCanvasBase.draw_idle
. Callrelim
to update the axes limits if desired.Note:
relim
will not see collections even if the collection was added to the axes with autolim = True.Note: there is no support for removing the artist's legend entry.
-
remove_callback
(oid)¶ Remove a callback based on its observer id.
See also
-
set
(**kwargs)¶ A property batch setter. Pass kwargs to set properties.
-
set_aa
(aa)¶ Alias for
set_antialiased
.
-
set_agg_filter
(filter_func)¶ Set the agg filter.
Parameters: - filter_funccallable
A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.
-
set_alpha
(alpha)¶ Set the alpha value used for blending - not supported on all backends.
Parameters: - alphafloat or None
-
set_animated
(b)¶ Set the artist's animation state.
Parameters: - bbool
-
set_antialiased
(aa)¶ Set the antialiasing state for rendering.
Parameters: - aabool or list of bools
-
set_antialiaseds
(aa)¶ Alias for
set_antialiased
.
-
set_array
(A)¶ Set the image array from numpy array A.
Parameters: - Andarray
-
set_capstyle
(cs)¶ Set the capstyle for the collection (for all its elements).
Parameters: - cs{'butt', 'round', 'projecting'}
The capstyle.
-
set_clim
(vmin=None, vmax=None)¶ Set the norm limits for image scaling.
Parameters: - vmin, vmaxfloat
The limits.
The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
-
set_clip_on
(b)¶ Set whether the artist uses clipping.
When False artists will be visible outside of the axes which can lead to unexpected results.
Parameters: - bbool
-
set_clip_path
(path, transform=None)¶ Set the artist's clip path.
Parameters: - path
Patch
orPath
orTransformedPath
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
Transform
, optional Only used if path is a
Path
, in which case the givenPath
is converted to aTransformedPath
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 toNone
.For technical reasons (support of
set
), a tuple (path, transform) is also accepted as a single positional parameter.- path
-
set_color
(c)¶ Set both the edgecolor and the facecolor.
Parameters: - ccolor or list of rgba tuples
See also
Collection.set_facecolor
,Collection.set_edgecolor
- For setting the edge or face color individually.
-
set_contains
(picker)¶ [Deprecated] Define a custom contains test for the artist.
The provided callable replaces the default
contains
method of the artist.Parameters: - pickercallable
A custom picker function to evaluate if an event is within the artist. The function must have the signature:
def contains(artist: Artist, event: MouseEvent) -> bool, dict
that returns:
- a bool indicating if the event is within the artist
- a dict of additional information. The dict should at least
return the same information as the default
contains()
implementation of the respective artist, but may provide additional information.
Notes
Deprecated since version 3.3.
-
set_dashes
(ls)¶ Alias for
set_linestyle
.
-
set_ec
(c)¶ Alias for
set_edgecolor
.
-
set_edgecolor
(c)¶ Set the edgecolor(s) of the collection.
Parameters: - ccolor or list of colors or 'face'
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
-
set_edgecolors
(c)¶ Alias for
set_edgecolor
.
-
set_facecolor
(c)¶ Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Parameters: - ccolor or list of colors
-
set_facecolors
(c)¶ Alias for
set_facecolor
.
-
set_fc
(c)¶ Alias for
set_facecolor
.
-
set_gid
(gid)¶ Set the (group) id for the artist.
Parameters: - gidstr
-
set_hatch
(hatch)¶ Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Parameters: - hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
-
set_in_layout
(in_layout)¶ Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.Parameters: - in_layoutbool
-
set_joinstyle
(js)¶ Set the joinstyle for the collection (for all its elements).
Parameters: - js{'miter', 'round', 'bevel'}
The joinstyle.
-
set_label
(s)¶ Set a label that will be displayed in the legend.
Parameters: - sobject
s will be converted to a string by calling
str
.
-
set_linestyle
(ls)¶ Set the linestyle(s) for the collection.
linestyle description '-'
or'solid'
solid line '--'
or'dashed'
dashed line '-.'
or'dashdot'
dash-dotted line ':'
or'dotted'
dotted line Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.Parameters: - lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for a complete description.
-
set_linestyles
(ls)¶ Alias for
set_linestyle
.
-
set_linewidth
(lw)¶ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Parameters: - lwfloat or list of floats
-
set_linewidths
(lw)¶ Alias for
set_linewidth
.
-
set_ls
(ls)¶ Alias for
set_linestyle
.
-
set_lw
(lw)¶ Alias for
set_linewidth
.
-
set_norm
(norm)¶ Set the normalization instance.
Parameters: - norm
Normalize
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.
- norm
-
set_offset_position
(offset_position)¶ [Deprecated] Set how offsets are applied. If offset_position is 'screen' (default) the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Parameters: - offset_position{'screen', 'data'}
Notes
Deprecated since version 3.3.
-
set_offsets
(offsets)¶ Set the offsets for the collection.
Parameters: - offsetsarray-like (N, 2) or (2,)
-
set_path_effects
(path_effects)¶ Set the path effects.
Parameters: - path_effects
AbstractPathEffect
- path_effects
-
set_paths
()¶
-
set_picker
(picker)¶ Define the picking behavior of the artist.
Parameters: - pickerNone or bool or callable
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A 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.
deprecated: For
Line2D
only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. UseLine2D.set_pickradius
instead.
-
set_pickradius
(pr)¶ Set the pick radius used for containment tests.
Parameters: - dfloat
Pick radius, in points.
-
set_rasterized
(rasterized)¶ Force rasterized (bitmap) drawing in vector backend output.
Defaults to None, which implies the backend's default behavior.
Parameters: - rasterizedbool or None
-
set_sizes
(sizes, dpi=72.0)¶ Set the sizes of each member of the collection.
Parameters: - sizesndarray or None
The size to set for each element of the collection. The value is the 'area' of the element.
- dpifloat, default: 72
The dpi of the canvas.
-
set_sketch_params
(scale=None, length=None, randomness=None)¶ Sets the sketch parameters.
Parameters: - scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is
None
, or not provided, no sketch filter will be provided.- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
-
set_snap
(snap)¶ Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters: - snapbool or None
Possible values:
- True: Snap vertices to the nearest pixel center.
- False: Do not modify vertex positions.
- None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
-
set_url
(url)¶ Set the url for the artist.
Parameters: - urlstr
-
set_urls
(urls)¶ Parameters: - urlslist of str or None
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
-
set_visible
(b)¶ Set the artist's visibility.
Parameters: - bbool
-
set_zorder
(level)¶ Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters: - levelfloat
-
property
stale
¶ Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
-
property
sticky_edges
¶ x
andy
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.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
-
to_rgba
(x, alpha=None, bytes=False, norm=True)¶ Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
-
update
(props)¶ Update this artist's properties from the dict props.
Parameters: - propsdict
-
property
update_dict
¶
-
update_from
(other)¶ Copy properties from other to self.
-
update_scalarmappable
()¶ Update colors from the scalar mappable array, if it is not None.
-
zorder
= 0¶
-
class
matplotlib.collections.
BrokenBarHCollection
(xranges, yrange, **kwargs)[source]¶ Bases:
matplotlib.collections.PolyCollection
A collection of horizontal bars spanning yrange with a sequence of xranges.
Parameters: - xrangeslist of (float, float)
The sequence of (left-edge-position, width) pairs for each bar.
- yrange(float, float)
The (lower-edge, height) common to all bars.
- **kwargs
Forwarded to
Collection
.
-
add_callback
(func)¶ Add a callback function that will be called whenever one of the
Artist
's properties changes.Parameters: - funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling
Artist
. Return values may exist but are ignored.
Returns: - int
The observer id associated with the callback. This id can be used for removing the callback with
remove_callback
later.
See also
-
add_checker
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
autoscale
()¶ Autoscale the scalar limits on the norm instance using the current array
-
autoscale_None
()¶ Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
-
changed
()¶ Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
-
check_update
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
contains
(mouseevent)¶ Test whether the mouse event occurred in the collection.
Returns
bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
-
convert_xunits
(x)¶ Convert x using the unit type of the xaxis.
If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.
-
convert_yunits
(y)¶ Convert y using the unit type of the yaxis.
If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.
-
draw
(renderer)¶ Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visible
returns False).Parameters: - renderer
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
- renderer
-
findobj
(match=None, include_self=True)¶ Find artist objects.
Recursively find all
Artist
instances contained in the artist.Parameters: - match
A filter criterion for the matches. This can be
- None: Return all objects contained in artist.
- A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True. - A class instance: e.g.,
Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
- include_selfbool
Include self in the list to be checked for a match.
Returns: - list of
Artist
-
format_cursor_data
(data)¶ 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.
See also
-
get_agg_filter
()¶ Return filter function to be used for agg filter.
-
get_alpha
()¶ Return the alpha value used for blending - not supported on all backends.
-
get_animated
()¶ Return whether the artist is animated.
-
get_array
()¶ Return the data array.
-
get_capstyle
()¶
-
get_clim
()¶ Return the values (min, max) that are mapped to the colormap limits.
-
get_clip_box
()¶ Return the clipbox.
-
get_clip_on
()¶ Return whether the artist uses clipping.
-
get_clip_path
()¶ Return the clip path.
-
get_contains
()¶ [Deprecated] Return the custom contains function of the artist if set, or None.
See also
Notes
Deprecated since version 3.3.
-
get_cursor_data
(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.Parameters: See also
-
get_dashes
()¶ Alias for
get_linestyle
.
-
get_datalim
(transData)¶
-
get_ec
()¶ Alias for
get_edgecolor
.
-
get_edgecolor
()¶
-
get_edgecolors
()¶ Alias for
get_edgecolor
.
-
get_facecolor
()¶
-
get_facecolors
()¶ Alias for
get_facecolor
.
-
get_fc
()¶ Alias for
get_facecolor
.
-
get_fill
()¶ Return whether fill is set.
-
get_gid
()¶ Return the group id.
-
get_hatch
()¶ Return the current hatching pattern.
-
get_in_layout
()¶ Return boolean flag,
True
if artist is included in layout calculations.E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.
-
get_joinstyle
()¶
-
get_label
()¶ Return the label used for this artist in the legend.
-
get_linestyle
()¶
-
get_linestyles
()¶ Alias for
get_linestyle
.
-
get_linewidth
()¶
-
get_linewidths
()¶ Alias for
get_linewidth
.
-
get_ls
()¶ Alias for
get_linestyle
.
-
get_lw
()¶ Alias for
get_linewidth
.
-
get_offset_position
()¶ [Deprecated] Return how offsets are applied for the collection. If offset_position is 'screen', the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Notes
Deprecated since version 3.3.
-
get_offset_transform
()¶
-
get_offsets
()¶ Return the offsets for the collection.
-
get_path_effects
()¶
-
get_paths
()¶
-
get_picker
()¶ Return the picking behavior of the artist.
The possible values are described in
set_picker
.See also
-
get_pickradius
()¶
-
get_rasterized
()¶ Return whether the artist is to be rasterized.
-
get_sizes
()¶ Return the sizes ('areas') of the elements in the collection.
Returns: - array
The 'area' of each element.
-
get_sketch_params
()¶ Return the sketch parameters for the artist.
Returns: - tuple or None
A 3-tuple with the following elements:
- scale: The amplitude of the wiggle perpendicular to the source line.
- length: The length of the wiggle along the line.
- randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
-
get_tightbbox
(renderer)¶ Like
Artist.get_window_extent
, but includes any clipping.Parameters: - renderer
RendererBase
subclass renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
Returns: Bbox
The enclosing bounding box (in figure pixel coordinates).
- renderer
-
get_transformed_clip_path_and_affine
()¶ Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
-
get_transforms
()¶
-
get_url
()¶ Return the url.
-
get_urls
()¶ Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
-
get_visible
()¶ Return the visibility.
-
get_window_extent
(renderer)¶ Get the axes bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
-
get_zorder
()¶ Return the artist's zorder.
-
have_units
()¶ Return True if units are set on any axis.
-
is_transform_set
()¶ Return whether the Artist has an explicitly set transform.
This is True after
set_transform
has been called.
-
property
mouseover
¶ If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also
get_cursor_data()
,ToolCursorPosition
andNavigationToolbar2
.
-
pchanged
()¶ Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
-
pick
(mouseevent)¶ Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
-
pickable
()¶ Return whether the artist is pickable.
See also
-
properties
()¶ Return a dictionary of all the properties of the artist.
-
remove
()¶ Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with
FigureCanvasBase.draw_idle
. Callrelim
to update the axes limits if desired.Note:
relim
will not see collections even if the collection was added to the axes with autolim = True.Note: there is no support for removing the artist's legend entry.
-
remove_callback
(oid)¶ Remove a callback based on its observer id.
See also
-
set
(**kwargs)¶ A property batch setter. Pass kwargs to set properties.
-
set_aa
(aa)¶ Alias for
set_antialiased
.
-
set_agg_filter
(filter_func)¶ Set the agg filter.
Parameters: - filter_funccallable
A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.
-
set_alpha
(alpha)¶ Set the alpha value used for blending - not supported on all backends.
Parameters: - alphafloat or None
-
set_animated
(b)¶ Set the artist's animation state.
Parameters: - bbool
-
set_antialiased
(aa)¶ Set the antialiasing state for rendering.
Parameters: - aabool or list of bools
-
set_antialiaseds
(aa)¶ Alias for
set_antialiased
.
-
set_array
(A)¶ Set the image array from numpy array A.
Parameters: - Andarray
-
set_capstyle
(cs)¶ Set the capstyle for the collection (for all its elements).
Parameters: - cs{'butt', 'round', 'projecting'}
The capstyle.
-
set_clim
(vmin=None, vmax=None)¶ Set the norm limits for image scaling.
Parameters: - vmin, vmaxfloat
The limits.
The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
-
set_clip_on
(b)¶ Set whether the artist uses clipping.
When False artists will be visible outside of the axes which can lead to unexpected results.
Parameters: - bbool
-
set_clip_path
(path, transform=None)¶ Set the artist's clip path.
Parameters: - path
Patch
orPath
orTransformedPath
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
Transform
, optional Only used if path is a
Path
, in which case the givenPath
is converted to aTransformedPath
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 toNone
.For technical reasons (support of
set
), a tuple (path, transform) is also accepted as a single positional parameter.- path
-
set_color
(c)¶ Set both the edgecolor and the facecolor.
Parameters: - ccolor or list of rgba tuples
See also
Collection.set_facecolor
,Collection.set_edgecolor
- For setting the edge or face color individually.
-
set_contains
(picker)¶ [Deprecated] Define a custom contains test for the artist.
The provided callable replaces the default
contains
method of the artist.Parameters: - pickercallable
A custom picker function to evaluate if an event is within the artist. The function must have the signature:
def contains(artist: Artist, event: MouseEvent) -> bool, dict
that returns:
- a bool indicating if the event is within the artist
- a dict of additional information. The dict should at least
return the same information as the default
contains()
implementation of the respective artist, but may provide additional information.
Notes
Deprecated since version 3.3.
-
set_dashes
(ls)¶ Alias for
set_linestyle
.
-
set_ec
(c)¶ Alias for
set_edgecolor
.
-
set_edgecolor
(c)¶ Set the edgecolor(s) of the collection.
Parameters: - ccolor or list of colors or 'face'
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
-
set_edgecolors
(c)¶ Alias for
set_edgecolor
.
-
set_facecolor
(c)¶ Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Parameters: - ccolor or list of colors
-
set_facecolors
(c)¶ Alias for
set_facecolor
.
-
set_fc
(c)¶ Alias for
set_facecolor
.
-
set_gid
(gid)¶ Set the (group) id for the artist.
Parameters: - gidstr
-
set_hatch
(hatch)¶ Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Parameters: - hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
-
set_in_layout
(in_layout)¶ Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.Parameters: - in_layoutbool
-
set_joinstyle
(js)¶ Set the joinstyle for the collection (for all its elements).
Parameters: - js{'miter', 'round', 'bevel'}
The joinstyle.
-
set_label
(s)¶ Set a label that will be displayed in the legend.
Parameters: - sobject
s will be converted to a string by calling
str
.
-
set_linestyle
(ls)¶ Set the linestyle(s) for the collection.
linestyle description '-'
or'solid'
solid line '--'
or'dashed'
dashed line '-.'
or'dashdot'
dash-dotted line ':'
or'dotted'
dotted line Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.Parameters: - lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for a complete description.
-
set_linestyles
(ls)¶ Alias for
set_linestyle
.
-
set_linewidth
(lw)¶ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Parameters: - lwfloat or list of floats
-
set_linewidths
(lw)¶ Alias for
set_linewidth
.
-
set_ls
(ls)¶ Alias for
set_linestyle
.
-
set_lw
(lw)¶ Alias for
set_linewidth
.
-
set_norm
(norm)¶ Set the normalization instance.
Parameters: - norm
Normalize
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.
- norm
-
set_offset_position
(offset_position)¶ [Deprecated] Set how offsets are applied. If offset_position is 'screen' (default) the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Parameters: - offset_position{'screen', 'data'}
Notes
Deprecated since version 3.3.
-
set_offsets
(offsets)¶ Set the offsets for the collection.
Parameters: - offsetsarray-like (N, 2) or (2,)
-
set_path_effects
(path_effects)¶ Set the path effects.
Parameters: - path_effects
AbstractPathEffect
- path_effects
-
set_paths
(verts, closed=True)¶ Set the vertices of the polygons.
Parameters: - vertslist of array-like
The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).
- closedbool, default: True
Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.
-
set_picker
(picker)¶ Define the picking behavior of the artist.
Parameters: - pickerNone or bool or callable
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A 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.
deprecated: For
Line2D
only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. UseLine2D.set_pickradius
instead.
-
set_pickradius
(pr)¶ Set the pick radius used for containment tests.
Parameters: - dfloat
Pick radius, in points.
-
set_rasterized
(rasterized)¶ Force rasterized (bitmap) drawing in vector backend output.
Defaults to None, which implies the backend's default behavior.
Parameters: - rasterizedbool or None
-
set_sizes
(sizes, dpi=72.0)¶ Set the sizes of each member of the collection.
Parameters: - sizesndarray or None
The size to set for each element of the collection. The value is the 'area' of the element.
- dpifloat, default: 72
The dpi of the canvas.
-
set_sketch_params
(scale=None, length=None, randomness=None)¶ Sets the sketch parameters.
Parameters: - scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is
None
, or not provided, no sketch filter will be provided.- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
-
set_snap
(snap)¶ Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters: - snapbool or None
Possible values:
- True: Snap vertices to the nearest pixel center.
- False: Do not modify vertex positions.
- None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
-
set_url
(url)¶ Set the url for the artist.
Parameters: - urlstr
-
set_urls
(urls)¶ Parameters: - urlslist of str or None
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
-
set_verts
(verts, closed=True)¶ Set the vertices of the polygons.
Parameters: - vertslist of array-like
The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).
- closedbool, default: True
Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.
-
set_verts_and_codes
(verts, codes)¶ Initialize vertices with path codes.
-
set_visible
(b)¶ Set the artist's visibility.
Parameters: - bbool
-
set_zorder
(level)¶ Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters: - levelfloat
-
classmethod
span_where
(x, ymin, ymax, where, **kwargs)[source]¶ Return a
BrokenBarHCollection
that plots horizontal bars from over the regions in x where where is True. The bars range on the y-axis from ymin to ymaxkwargs are passed on to the collection.
-
property
stale
¶ Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
-
property
sticky_edges
¶ x
andy
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.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
-
to_rgba
(x, alpha=None, bytes=False, norm=True)¶ Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
-
update
(props)¶ Update this artist's properties from the dict props.
Parameters: - propsdict
-
property
update_dict
¶
-
update_from
(other)¶ Copy properties from other to self.
-
update_scalarmappable
()¶ Update colors from the scalar mappable array, if it is not None.
-
zorder
= 0¶
-
class
matplotlib.collections.
CircleCollection
(sizes, **kwargs)[source]¶ Bases:
matplotlib.collections._CollectionWithSizes
A collection of circles, drawn using splines.
Parameters: - sizesfloat or array-like
The area of each circle in points^2.
- **kwargs
Forwarded to
Collection
.
-
add_callback
(func)¶ Add a callback function that will be called whenever one of the
Artist
's properties changes.Parameters: - funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling
Artist
. Return values may exist but are ignored.
Returns: - int
The observer id associated with the callback. This id can be used for removing the callback with
remove_callback
later.
See also
-
add_checker
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
autoscale
()¶ Autoscale the scalar limits on the norm instance using the current array
-
autoscale_None
()¶ Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
-
changed
()¶ Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
-
check_update
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
contains
(mouseevent)¶ Test whether the mouse event occurred in the collection.
Returns
bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
-
convert_xunits
(x)¶ Convert x using the unit type of the xaxis.
If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.
-
convert_yunits
(y)¶ Convert y using the unit type of the yaxis.
If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.
-
draw
(renderer)¶ Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visible
returns False).Parameters: - renderer
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
- renderer
-
findobj
(match=None, include_self=True)¶ Find artist objects.
Recursively find all
Artist
instances contained in the artist.Parameters: - match
A filter criterion for the matches. This can be
- None: Return all objects contained in artist.
- A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True. - A class instance: e.g.,
Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
- include_selfbool
Include self in the list to be checked for a match.
Returns: - list of
Artist
-
format_cursor_data
(data)¶ 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.
See also
-
get_agg_filter
()¶ Return filter function to be used for agg filter.
-
get_alpha
()¶ Return the alpha value used for blending - not supported on all backends.
-
get_animated
()¶ Return whether the artist is animated.
-
get_array
()¶ Return the data array.
-
get_capstyle
()¶
-
get_clim
()¶ Return the values (min, max) that are mapped to the colormap limits.
-
get_clip_box
()¶ Return the clipbox.
-
get_clip_on
()¶ Return whether the artist uses clipping.
-
get_clip_path
()¶ Return the clip path.
-
get_contains
()¶ [Deprecated] Return the custom contains function of the artist if set, or None.
See also
Notes
Deprecated since version 3.3.
-
get_cursor_data
(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.Parameters: See also
-
get_dashes
()¶ Alias for
get_linestyle
.
-
get_datalim
(transData)¶
-
get_ec
()¶ Alias for
get_edgecolor
.
-
get_edgecolor
()¶
-
get_edgecolors
()¶ Alias for
get_edgecolor
.
-
get_facecolor
()¶
-
get_facecolors
()¶ Alias for
get_facecolor
.
-
get_fc
()¶ Alias for
get_facecolor
.
-
get_fill
()¶ Return whether fill is set.
-
get_gid
()¶ Return the group id.
-
get_hatch
()¶ Return the current hatching pattern.
-
get_in_layout
()¶ Return boolean flag,
True
if artist is included in layout calculations.E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.
-
get_joinstyle
()¶
-
get_label
()¶ Return the label used for this artist in the legend.
-
get_linestyle
()¶
-
get_linestyles
()¶ Alias for
get_linestyle
.
-
get_linewidth
()¶
-
get_linewidths
()¶ Alias for
get_linewidth
.
-
get_ls
()¶ Alias for
get_linestyle
.
-
get_lw
()¶ Alias for
get_linewidth
.
-
get_offset_position
()¶ [Deprecated] Return how offsets are applied for the collection. If offset_position is 'screen', the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Notes
Deprecated since version 3.3.
-
get_offset_transform
()¶
-
get_offsets
()¶ Return the offsets for the collection.
-
get_path_effects
()¶
-
get_paths
()¶
-
get_picker
()¶ Return the picking behavior of the artist.
The possible values are described in
set_picker
.See also
-
get_pickradius
()¶
-
get_rasterized
()¶ Return whether the artist is to be rasterized.
-
get_sizes
()¶ Return the sizes ('areas') of the elements in the collection.
Returns: - array
The 'area' of each element.
-
get_sketch_params
()¶ Return the sketch parameters for the artist.
Returns: - tuple or None
A 3-tuple with the following elements:
- scale: The amplitude of the wiggle perpendicular to the source line.
- length: The length of the wiggle along the line.
- randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
-
get_tightbbox
(renderer)¶ Like
Artist.get_window_extent
, but includes any clipping.Parameters: - renderer
RendererBase
subclass renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
Returns: Bbox
The enclosing bounding box (in figure pixel coordinates).
- renderer
-
get_transformed_clip_path_and_affine
()¶ Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
-
get_transforms
()¶
-
get_url
()¶ Return the url.
-
get_urls
()¶ Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
-
get_visible
()¶ Return the visibility.
-
get_window_extent
(renderer)¶ Get the axes bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
-
get_zorder
()¶ Return the artist's zorder.
-
have_units
()¶ Return True if units are set on any axis.
-
is_transform_set
()¶ Return whether the Artist has an explicitly set transform.
This is True after
set_transform
has been called.
-
property
mouseover
¶ If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also
get_cursor_data()
,ToolCursorPosition
andNavigationToolbar2
.
-
pchanged
()¶ Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
-
pick
(mouseevent)¶ Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
-
pickable
()¶ Return whether the artist is pickable.
See also
-
properties
()¶ Return a dictionary of all the properties of the artist.
-
remove
()¶ Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with
FigureCanvasBase.draw_idle
. Callrelim
to update the axes limits if desired.Note:
relim
will not see collections even if the collection was added to the axes with autolim = True.Note: there is no support for removing the artist's legend entry.
-
remove_callback
(oid)¶ Remove a callback based on its observer id.
See also
-
set
(**kwargs)¶ A property batch setter. Pass kwargs to set properties.
-
set_aa
(aa)¶ Alias for
set_antialiased
.
-
set_agg_filter
(filter_func)¶ Set the agg filter.
Parameters: - filter_funccallable
A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.
-
set_alpha
(alpha)¶ Set the alpha value used for blending - not supported on all backends.
Parameters: - alphafloat or None
-
set_animated
(b)¶ Set the artist's animation state.
Parameters: - bbool
-
set_antialiased
(aa)¶ Set the antialiasing state for rendering.
Parameters: - aabool or list of bools
-
set_antialiaseds
(aa)¶ Alias for
set_antialiased
.
-
set_array
(A)¶ Set the image array from numpy array A.
Parameters: - Andarray
-
set_capstyle
(cs)¶ Set the capstyle for the collection (for all its elements).
Parameters: - cs{'butt', 'round', 'projecting'}
The capstyle.
-
set_clim
(vmin=None, vmax=None)¶ Set the norm limits for image scaling.
Parameters: - vmin, vmaxfloat
The limits.
The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
-
set_clip_on
(b)¶ Set whether the artist uses clipping.
When False artists will be visible outside of the axes which can lead to unexpected results.
Parameters: - bbool
-
set_clip_path
(path, transform=None)¶ Set the artist's clip path.
Parameters: - path
Patch
orPath
orTransformedPath
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
Transform
, optional Only used if path is a
Path
, in which case the givenPath
is converted to aTransformedPath
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 toNone
.For technical reasons (support of
set
), a tuple (path, transform) is also accepted as a single positional parameter.- path
-
set_color
(c)¶ Set both the edgecolor and the facecolor.
Parameters: - ccolor or list of rgba tuples
See also
Collection.set_facecolor
,Collection.set_edgecolor
- For setting the edge or face color individually.
-
set_contains
(picker)¶ [Deprecated] Define a custom contains test for the artist.
The provided callable replaces the default
contains
method of the artist.Parameters: - pickercallable
A custom picker function to evaluate if an event is within the artist. The function must have the signature:
def contains(artist: Artist, event: MouseEvent) -> bool, dict
that returns:
- a bool indicating if the event is within the artist
- a dict of additional information. The dict should at least
return the same information as the default
contains()
implementation of the respective artist, but may provide additional information.
Notes
Deprecated since version 3.3.
-
set_dashes
(ls)¶ Alias for
set_linestyle
.
-
set_ec
(c)¶ Alias for
set_edgecolor
.
-
set_edgecolor
(c)¶ Set the edgecolor(s) of the collection.
Parameters: - ccolor or list of colors or 'face'
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
-
set_edgecolors
(c)¶ Alias for
set_edgecolor
.
-
set_facecolor
(c)¶ Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Parameters: - ccolor or list of colors
-
set_facecolors
(c)¶ Alias for
set_facecolor
.
-
set_fc
(c)¶ Alias for
set_facecolor
.
-
set_gid
(gid)¶ Set the (group) id for the artist.
Parameters: - gidstr
-
set_hatch
(hatch)¶ Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Parameters: - hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
-
set_in_layout
(in_layout)¶ Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.Parameters: - in_layoutbool
-
set_joinstyle
(js)¶ Set the joinstyle for the collection (for all its elements).
Parameters: - js{'miter', 'round', 'bevel'}
The joinstyle.
-
set_label
(s)¶ Set a label that will be displayed in the legend.
Parameters: - sobject
s will be converted to a string by calling
str
.
-
set_linestyle
(ls)¶ Set the linestyle(s) for the collection.
linestyle description '-'
or'solid'
solid line '--'
or'dashed'
dashed line '-.'
or'dashdot'
dash-dotted line ':'
or'dotted'
dotted line Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.Parameters: - lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for a complete description.
-
set_linestyles
(ls)¶ Alias for
set_linestyle
.
-
set_linewidth
(lw)¶ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Parameters: - lwfloat or list of floats
-
set_linewidths
(lw)¶ Alias for
set_linewidth
.
-
set_ls
(ls)¶ Alias for
set_linestyle
.
-
set_lw
(lw)¶ Alias for
set_linewidth
.
-
set_norm
(norm)¶ Set the normalization instance.
Parameters: - norm
Normalize
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.
- norm
-
set_offset_position
(offset_position)¶ [Deprecated] Set how offsets are applied. If offset_position is 'screen' (default) the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Parameters: - offset_position{'screen', 'data'}
Notes
Deprecated since version 3.3.
-
set_offsets
(offsets)¶ Set the offsets for the collection.
Parameters: - offsetsarray-like (N, 2) or (2,)
-
set_path_effects
(path_effects)¶ Set the path effects.
Parameters: - path_effects
AbstractPathEffect
- path_effects
-
set_paths
()¶
-
set_picker
(picker)¶ Define the picking behavior of the artist.
Parameters: - pickerNone or bool or callable
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A 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.
deprecated: For
Line2D
only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. UseLine2D.set_pickradius
instead.
-
set_pickradius
(pr)¶ Set the pick radius used for containment tests.
Parameters: - dfloat
Pick radius, in points.
-
set_rasterized
(rasterized)¶ Force rasterized (bitmap) drawing in vector backend output.
Defaults to None, which implies the backend's default behavior.
Parameters: - rasterizedbool or None
-
set_sizes
(sizes, dpi=72.0)¶ Set the sizes of each member of the collection.
Parameters: - sizesndarray or None
The size to set for each element of the collection. The value is the 'area' of the element.
- dpifloat, default: 72
The dpi of the canvas.
-
set_sketch_params
(scale=None, length=None, randomness=None)¶ Sets the sketch parameters.
Parameters: - scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is
None
, or not provided, no sketch filter will be provided.- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
-
set_snap
(snap)¶ Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters: - snapbool or None
Possible values:
- True: Snap vertices to the nearest pixel center.
- False: Do not modify vertex positions.
- None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
-
set_url
(url)¶ Set the url for the artist.
Parameters: - urlstr
-
set_urls
(urls)¶ Parameters: - urlslist of str or None
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
-
set_visible
(b)¶ Set the artist's visibility.
Parameters: - bbool
-
set_zorder
(level)¶ Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters: - levelfloat
-
property
stale
¶ Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
-
property
sticky_edges
¶ x
andy
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.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
-
to_rgba
(x, alpha=None, bytes=False, norm=True)¶ Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
-
update
(props)¶ Update this artist's properties from the dict props.
Parameters: - propsdict
-
property
update_dict
¶
-
update_from
(other)¶ Copy properties from other to self.
-
update_scalarmappable
()¶ Update colors from the scalar mappable array, if it is not None.
-
zorder
= 0¶
-
class
matplotlib.collections.
Collection
(edgecolors=None, facecolors=None, linewidths=None, linestyles='solid', capstyle=None, joinstyle=None, antialiaseds=None, offsets=None, transOffset=None, norm=None, cmap=None, pickradius=5.0, hatch=None, urls=None, offset_position=<deprecated parameter>, zorder=1, **kwargs)[source]¶ Bases:
matplotlib.artist.Artist
,matplotlib.cm.ScalarMappable
Base class for Collections. Must be subclassed to be usable.
A Collection represents a sequence of
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 adraw_marker()
call much more efficiently than a series of repeated calls todraw_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 ofPatch.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:prop[i % len(prop)]
Each Collection can optionally be used as its own
ScalarMappable
by passing the norm and cmap parameters to its constructor. If the Collection'sScalarMappable
matrix_A
has been set (via a call toCollection.set_array
), then at draw time this internal scalar mappable will be used to set thefacecolors
andedgecolors
, ignoring those that were manually passed in.Parameters: - edgecolorscolor or list of colors, default:
rcParams["patch.edgecolor"]
(default:'black'
) Edge color for each patch making up the collection. The special value 'face' can be passed to make the edgecolor match the facecolor.
- facecolorscolor or list of colors, default:
rcParams["patch.facecolor"]
(default:'C0'
) Face color for each patch making up the collection.
- linewidthsfloat or list of floats, default:
rcParams["patch.linewidth"]
(default:1.0
) Line width for each patch making up the collection.
- linestylesstr or tuple or list thereof, default: 'solid'
Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:
(offset, onoffseq),
where onoffseq is an even length tuple of on and off ink lengths in points. For examples, see Linestyles.
- capstylestr, default:
rcParams["patch.capstyle"]
Style to use for capping lines for all paths in the collection. See Join styles and cap styles for a demonstration of each of the allowed values.
- joinstylestr, default:
rcParams["patch.joinstyle"]
Style to use for joining lines for all paths in the collection. See Join styles and cap styles for a demonstration of each of the allowed values.
- antialiasedsbool or list of bool, default:
rcParams["patch.antialiased"]
(default:True
) Whether each pach in the collection should be drawn with antialiasing.
- offsets(float, float) or list thereof, default: (0, 0)
A vector by which to translate each patch after rendering (default is no translation). The translation is performed in screen (pixel) coordinates (i.e. after the Artist's transform is applied).
- transOffset
Transform
, default:IdentityTransform
A single transform which will be applied to each offsets vector before it is used.
- offset_position{'screen' (default), 'data' (deprecated)}
If set to 'data' (deprecated), offsets will be treated as if it is in data coordinates instead of in screen coordinates.
- norm
Normalize
, optional Forwarded to
ScalarMappable
. The default ofNone
means that the first draw call will setvmin
andvmax
using the minimum and maximum values of the data.- cmap
Colormap
, optional Forwarded to
ScalarMappable
. The default ofNone
will result inrcParams["image.cmap"]
(default:'viridis'
) being used.- hatchstr, optional
Hatching pattern to use in filled paths, if any. Valid strings are ['/', '', '|', '-', '+', 'x', 'o', 'O', '.', '*']. See Hatch Demo for the meaning of each hatch type.
- pickradiusfloat, default: 5.0
If
pickradius <= 0
, thenCollection.contains
will returnTrue
whenever the test point is inside of one of the 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 width2*pickradius
following any of the Paths in the Collection.- urlslist of str, default: None
A URL for each patch to link to once drawn. Currently only works for the SVG backend. See Hyperlinks for examples.
- zorderfloat, default: 1
The drawing order, shared by all Patches in the Collection. See Zorder Demo for all defaults and examples.
-
add_callback
(func)¶ Add a callback function that will be called whenever one of the
Artist
's properties changes.Parameters: - funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling
Artist
. Return values may exist but are ignored.
Returns: - int
The observer id associated with the callback. This id can be used for removing the callback with
remove_callback
later.
See also
-
add_checker
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
autoscale
()¶ Autoscale the scalar limits on the norm instance using the current array
-
autoscale_None
()¶ Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
-
changed
()¶ Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
-
check_update
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
contains
(mouseevent)[source]¶ Test whether the mouse event occurred in the collection.
Returns
bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
-
convert_xunits
(x)¶ Convert x using the unit type of the xaxis.
If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.
-
convert_yunits
(y)¶ Convert y using the unit type of the yaxis.
If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.
-
draw
(renderer)[source]¶ Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visible
returns False).Parameters: - renderer
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
- renderer
-
findobj
(match=None, include_self=True)¶ Find artist objects.
Recursively find all
Artist
instances contained in the artist.Parameters: - match
A filter criterion for the matches. This can be
- None: Return all objects contained in artist.
- A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True. - A class instance: e.g.,
Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
- include_selfbool
Include self in the list to be checked for a match.
Returns: - list of
Artist
-
format_cursor_data
(data)¶ 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.
See also
-
get_agg_filter
()¶ Return filter function to be used for agg filter.
-
get_alpha
()¶ Return the alpha value used for blending - not supported on all backends.
-
get_animated
()¶ Return whether the artist is animated.
-
get_array
()¶ Return the data array.
-
get_clim
()¶ Return the values (min, max) that are mapped to the colormap limits.
-
get_clip_box
()¶ Return the clipbox.
-
get_clip_on
()¶ Return whether the artist uses clipping.
-
get_clip_path
()¶ Return the clip path.
-
get_contains
()¶ [Deprecated] Return the custom contains function of the artist if set, or None.
See also
Notes
Deprecated since version 3.3.
-
get_cursor_data
(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.Parameters: See also
-
get_dashes
()¶ Alias for
get_linestyle
.
-
get_ec
()¶ Alias for
get_edgecolor
.
-
get_edgecolors
()¶ Alias for
get_edgecolor
.
-
get_facecolors
()¶ Alias for
get_facecolor
.
-
get_fc
()¶ Alias for
get_facecolor
.
-
get_gid
()¶ Return the group id.
-
get_in_layout
()¶ Return boolean flag,
True
if artist is included in layout calculations.E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.
-
get_label
()¶ Return the label used for this artist in the legend.
-
get_linestyles
()¶ Alias for
get_linestyle
.
-
get_linewidths
()¶ Alias for
get_linewidth
.
-
get_ls
()¶ Alias for
get_linestyle
.
-
get_lw
()¶ Alias for
get_linewidth
.
-
get_offset_position
()[source]¶ [Deprecated] Return how offsets are applied for the collection. If offset_position is 'screen', the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Notes
Deprecated since version 3.3.
-
get_path_effects
()¶
-
get_picker
()¶ Return the picking behavior of the artist.
The possible values are described in
set_picker
.See also
-
get_rasterized
()¶ Return whether the artist is to be rasterized.
-
get_sketch_params
()¶ Return the sketch parameters for the artist.
Returns: - tuple or None
A 3-tuple with the following elements:
- scale: The amplitude of the wiggle perpendicular to the source line.
- length: The length of the wiggle along the line.
- randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
-
get_tightbbox
(renderer)¶ Like
Artist.get_window_extent
, but includes any clipping.Parameters: - renderer
RendererBase
subclass renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
Returns: Bbox
The enclosing bounding box (in figure pixel coordinates).
- renderer
-
get_transformed_clip_path_and_affine
()¶ Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
-
get_url
()¶ Return the url.
-
get_urls
()[source]¶ Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
-
get_visible
()¶ Return the visibility.
-
get_window_extent
(renderer)[source]¶ Get the axes bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
-
get_zorder
()¶ Return the artist's zorder.
-
have_units
()¶ Return True if units are set on any axis.
-
is_transform_set
()¶ Return whether the Artist has an explicitly set transform.
This is True after
set_transform
has been called.
-
property
mouseover
¶ If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also
get_cursor_data()
,ToolCursorPosition
andNavigationToolbar2
.
-
pchanged
()¶ Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
-
pick
(mouseevent)¶ Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
-
pickable
()¶ Return whether the artist is pickable.
See also
-
properties
()¶ Return a dictionary of all the properties of the artist.
-
remove
()¶ Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with
FigureCanvasBase.draw_idle
. Callrelim
to update the axes limits if desired.Note:
relim
will not see collections even if the collection was added to the axes with autolim = True.Note: there is no support for removing the artist's legend entry.
-
remove_callback
(oid)¶ Remove a callback based on its observer id.
See also
-
set
(**kwargs)¶ A property batch setter. Pass kwargs to set properties.
-
set_aa
(aa)¶ Alias for
set_antialiased
.
-
set_agg_filter
(filter_func)¶ Set the agg filter.
Parameters: - filter_funccallable
A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.
-
set_alpha
(alpha)[source]¶ Set the alpha value used for blending - not supported on all backends.
Parameters: - alphafloat or None
-
set_animated
(b)¶ Set the artist's animation state.
Parameters: - bbool
-
set_antialiased
(aa)[source]¶ Set the antialiasing state for rendering.
Parameters: - aabool or list of bools
-
set_antialiaseds
(aa)¶ Alias for
set_antialiased
.
-
set_array
(A)¶ Set the image array from numpy array A.
Parameters: - Andarray
-
set_capstyle
(cs)[source]¶ Set the capstyle for the collection (for all its elements).
Parameters: - cs{'butt', 'round', 'projecting'}
The capstyle.
-
set_clim
(vmin=None, vmax=None)¶ Set the norm limits for image scaling.
Parameters: - vmin, vmaxfloat
The limits.
The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
-
set_clip_on
(b)¶ Set whether the artist uses clipping.
When False artists will be visible outside of the axes which can lead to unexpected results.
Parameters: - bbool
-
set_clip_path
(path, transform=None)¶ Set the artist's clip path.
Parameters: - path
Patch
orPath
orTransformedPath
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
Transform
, optional Only used if path is a
Path
, in which case the givenPath
is converted to aTransformedPath
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 toNone
.For technical reasons (support of
set
), a tuple (path, transform) is also accepted as a single positional parameter.- path
-
set_color
(c)[source]¶ Set both the edgecolor and the facecolor.
Parameters: - ccolor or list of rgba tuples
See also
Collection.set_facecolor
,Collection.set_edgecolor
- For setting the edge or face color individually.
-
set_contains
(picker)¶ [Deprecated] Define a custom contains test for the artist.
The provided callable replaces the default
contains
method of the artist.Parameters: - pickercallable
A custom picker function to evaluate if an event is within the artist. The function must have the signature:
def contains(artist: Artist, event: MouseEvent) -> bool, dict
that returns:
- a bool indicating if the event is within the artist
- a dict of additional information. The dict should at least
return the same information as the default
contains()
implementation of the respective artist, but may provide additional information.
Notes
Deprecated since version 3.3.
-
set_dashes
(ls)¶ Alias for
set_linestyle
.
-
set_ec
(c)¶ Alias for
set_edgecolor
.
-
set_edgecolor
(c)[source]¶ Set the edgecolor(s) of the collection.
Parameters: - ccolor or list of colors or 'face'
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
-
set_edgecolors
(c)¶ Alias for
set_edgecolor
.
-
set_facecolor
(c)[source]¶ Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Parameters: - ccolor or list of colors
-
set_facecolors
(c)¶ Alias for
set_facecolor
.
-
set_fc
(c)¶ Alias for
set_facecolor
.
-
set_gid
(gid)¶ Set the (group) id for the artist.
Parameters: - gidstr
-
set_hatch
(hatch)[source]¶ Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Parameters: - hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
-
set_in_layout
(in_layout)¶ Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.Parameters: - in_layoutbool
-
set_joinstyle
(js)[source]¶ Set the joinstyle for the collection (for all its elements).
Parameters: - js{'miter', 'round', 'bevel'}
The joinstyle.
-
set_label
(s)¶ Set a label that will be displayed in the legend.
Parameters: - sobject
s will be converted to a string by calling
str
.
-
set_linestyle
(ls)[source]¶ Set the linestyle(s) for the collection.
linestyle description '-'
or'solid'
solid line '--'
or'dashed'
dashed line '-.'
or'dashdot'
dash-dotted line ':'
or'dotted'
dotted line Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.Parameters: - lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for a complete description.
-
set_linestyles
(ls)¶ Alias for
set_linestyle
.
-
set_linewidth
(lw)[source]¶ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Parameters: - lwfloat or list of floats
-
set_linewidths
(lw)¶ Alias for
set_linewidth
.
-
set_ls
(ls)¶ Alias for
set_linestyle
.
-
set_lw
(lw)¶ Alias for
set_linewidth
.
-
set_norm
(norm)¶ Set the normalization instance.
Parameters: - norm
Normalize
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.
- norm
-
set_offset_position
(offset_position)[source]¶ [Deprecated] Set how offsets are applied. If offset_position is 'screen' (default) the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Parameters: - offset_position{'screen', 'data'}
Notes
Deprecated since version 3.3.
-
set_offsets
(offsets)[source]¶ Set the offsets for the collection.
Parameters: - offsetsarray-like (N, 2) or (2,)
-
set_path_effects
(path_effects)¶ Set the path effects.
Parameters: - path_effects
AbstractPathEffect
- path_effects
-
set_picker
(picker)¶ Define the picking behavior of the artist.
Parameters: - pickerNone or bool or callable
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A 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.
deprecated: For
Line2D
only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. UseLine2D.set_pickradius
instead.
-
set_pickradius
(pr)[source]¶ Set the pick radius used for containment tests.
Parameters: - dfloat
Pick radius, in points.
-
set_rasterized
(rasterized)¶ Force rasterized (bitmap) drawing in vector backend output.
Defaults to None, which implies the backend's default behavior.
Parameters: - rasterizedbool or None
-
set_sketch_params
(scale=None, length=None, randomness=None)¶ Sets the sketch parameters.
Parameters: - scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is
None
, or not provided, no sketch filter will be provided.- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
-
set_snap
(snap)¶ Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters: - snapbool or None
Possible values:
- True: Snap vertices to the nearest pixel center.
- False: Do not modify vertex positions.
- None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
-
set_url
(url)¶ Set the url for the artist.
Parameters: - urlstr
-
set_urls
(urls)[source]¶ Parameters: - urlslist of str or None
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
-
set_visible
(b)¶ Set the artist's visibility.
Parameters: - bbool
-
set_zorder
(level)¶ Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters: - levelfloat
-
property
stale
¶ Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
-
property
sticky_edges
¶ x
andy
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.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
-
to_rgba
(x, alpha=None, bytes=False, norm=True)¶ Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
-
update
(props)¶ Update this artist's properties from the dict props.
Parameters: - propsdict
-
property
update_dict
¶
-
zorder
= 0¶
- edgecolorscolor or list of colors, default:
-
class
matplotlib.collections.
EllipseCollection
(widths, heights, angles, units='points', **kwargs)[source]¶ Bases:
matplotlib.collections.Collection
A collection of ellipses, drawn using splines.
Parameters: - widthsarray-like
The lengths of the first axes (e.g., major axis lengths).
- heightsarray-like
The lengths of second axes.
- anglesarray-like
The angles of the first axes, degrees CCW from the x-axis.
- units{'points', 'inches', 'dots', 'width', 'height', 'x', 'y', 'xy'}
The units in which majors and minors are given; 'width' and 'height' refer to the dimensions of the axes, while 'x' and 'y' refer to the offsets data units. 'xy' differs from all others in that the angle as plotted varies with the aspect ratio, and equals the specified angle only when the aspect ratio is unity. Hence it behaves the same as the
Ellipse
withaxes.transData
as its transform.- **kwargs
Forwarded to
Collection
.
-
add_callback
(func)¶ Add a callback function that will be called whenever one of the
Artist
's properties changes.Parameters: - funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling
Artist
. Return values may exist but are ignored.
Returns: - int
The observer id associated with the callback. This id can be used for removing the callback with
remove_callback
later.
See also
-
add_checker
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
autoscale
()¶ Autoscale the scalar limits on the norm instance using the current array
-
autoscale_None
()¶ Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
-
changed
()¶ Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
-
check_update
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
contains
(mouseevent)¶ Test whether the mouse event occurred in the collection.
Returns
bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
-
convert_xunits
(x)¶ Convert x using the unit type of the xaxis.
If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.
-
convert_yunits
(y)¶ Convert y using the unit type of the yaxis.
If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.
-
draw
(renderer)[source]¶ Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visible
returns False).Parameters: - renderer
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
- renderer
-
findobj
(match=None, include_self=True)¶ Find artist objects.
Recursively find all
Artist
instances contained in the artist.Parameters: - match
A filter criterion for the matches. This can be
- None: Return all objects contained in artist.
- A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True. - A class instance: e.g.,
Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
- include_selfbool
Include self in the list to be checked for a match.
Returns: - list of
Artist
-
format_cursor_data
(data)¶ 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.
See also
-
get_agg_filter
()¶ Return filter function to be used for agg filter.
-
get_alpha
()¶ Return the alpha value used for blending - not supported on all backends.
-
get_animated
()¶ Return whether the artist is animated.
-
get_array
()¶ Return the data array.
-
get_capstyle
()¶
-
get_clim
()¶ Return the values (min, max) that are mapped to the colormap limits.
-
get_clip_box
()¶ Return the clipbox.
-
get_clip_on
()¶ Return whether the artist uses clipping.
-
get_clip_path
()¶ Return the clip path.
-
get_contains
()¶ [Deprecated] Return the custom contains function of the artist if set, or None.
See also
Notes
Deprecated since version 3.3.
-
get_cursor_data
(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.Parameters: See also
-
get_dashes
()¶ Alias for
get_linestyle
.
-
get_datalim
(transData)¶
-
get_ec
()¶ Alias for
get_edgecolor
.
-
get_edgecolor
()¶
-
get_edgecolors
()¶ Alias for
get_edgecolor
.
-
get_facecolor
()¶
-
get_facecolors
()¶ Alias for
get_facecolor
.
-
get_fc
()¶ Alias for
get_facecolor
.
-
get_fill
()¶ Return whether fill is set.
-
get_gid
()¶ Return the group id.
-
get_hatch
()¶ Return the current hatching pattern.
-
get_in_layout
()¶ Return boolean flag,
True
if artist is included in layout calculations.E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.
-
get_joinstyle
()¶
-
get_label
()¶ Return the label used for this artist in the legend.
-
get_linestyle
()¶
-
get_linestyles
()¶ Alias for
get_linestyle
.
-
get_linewidth
()¶
-
get_linewidths
()¶ Alias for
get_linewidth
.
-
get_ls
()¶ Alias for
get_linestyle
.
-
get_lw
()¶ Alias for
get_linewidth
.
-
get_offset_position
()¶ [Deprecated] Return how offsets are applied for the collection. If offset_position is 'screen', the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Notes
Deprecated since version 3.3.
-
get_offset_transform
()¶
-
get_offsets
()¶ Return the offsets for the collection.
-
get_path_effects
()¶
-
get_paths
()¶
-
get_picker
()¶ Return the picking behavior of the artist.
The possible values are described in
set_picker
.See also
-
get_pickradius
()¶
-
get_rasterized
()¶ Return whether the artist is to be rasterized.
-
get_sketch_params
()¶ Return the sketch parameters for the artist.
Returns: - tuple or None
A 3-tuple with the following elements:
- scale: The amplitude of the wiggle perpendicular to the source line.
- length: The length of the wiggle along the line.
- randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
-
get_tightbbox
(renderer)¶ Like
Artist.get_window_extent
, but includes any clipping.Parameters: - renderer
RendererBase
subclass renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
Returns: Bbox
The enclosing bounding box (in figure pixel coordinates).
- renderer
-
get_transformed_clip_path_and_affine
()¶ Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
-
get_transforms
()¶
-
get_url
()¶ Return the url.
-
get_urls
()¶ Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
-
get_visible
()¶ Return the visibility.
-
get_window_extent
(renderer)¶ Get the axes bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
-
get_zorder
()¶ Return the artist's zorder.
-
have_units
()¶ Return True if units are set on any axis.
-
is_transform_set
()¶ Return whether the Artist has an explicitly set transform.
This is True after
set_transform
has been called.
-
property
mouseover
¶ If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also
get_cursor_data()
,ToolCursorPosition
andNavigationToolbar2
.
-
pchanged
()¶ Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
-
pick
(mouseevent)¶ Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
-
pickable
()¶ Return whether the artist is pickable.
See also
-
properties
()¶ Return a dictionary of all the properties of the artist.
-
remove
()¶ Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with
FigureCanvasBase.draw_idle
. Callrelim
to update the axes limits if desired.Note:
relim
will not see collections even if the collection was added to the axes with autolim = True.Note: there is no support for removing the artist's legend entry.
-
remove_callback
(oid)¶ Remove a callback based on its observer id.
See also
-
set
(**kwargs)¶ A property batch setter. Pass kwargs to set properties.
-
set_aa
(aa)¶ Alias for
set_antialiased
.
-
set_agg_filter
(filter_func)¶ Set the agg filter.
Parameters: - filter_funccallable
A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.
-
set_alpha
(alpha)¶ Set the alpha value used for blending - not supported on all backends.
Parameters: - alphafloat or None
-
set_animated
(b)¶ Set the artist's animation state.
Parameters: - bbool
-
set_antialiased
(aa)¶ Set the antialiasing state for rendering.
Parameters: - aabool or list of bools
-
set_antialiaseds
(aa)¶ Alias for
set_antialiased
.
-
set_array
(A)¶ Set the image array from numpy array A.
Parameters: - Andarray
-
set_capstyle
(cs)¶ Set the capstyle for the collection (for all its elements).
Parameters: - cs{'butt', 'round', 'projecting'}
The capstyle.
-
set_clim
(vmin=None, vmax=None)¶ Set the norm limits for image scaling.
Parameters: - vmin, vmaxfloat
The limits.
The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
-
set_clip_on
(b)¶ Set whether the artist uses clipping.
When False artists will be visible outside of the axes which can lead to unexpected results.
Parameters: - bbool
-
set_clip_path
(path, transform=None)¶ Set the artist's clip path.
Parameters: - path
Patch
orPath
orTransformedPath
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
Transform
, optional Only used if path is a
Path
, in which case the givenPath
is converted to aTransformedPath
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 toNone
.For technical reasons (support of
set
), a tuple (path, transform) is also accepted as a single positional parameter.- path
-
set_color
(c)¶ Set both the edgecolor and the facecolor.
Parameters: - ccolor or list of rgba tuples
See also
Collection.set_facecolor
,Collection.set_edgecolor
- For setting the edge or face color individually.
-
set_contains
(picker)¶ [Deprecated] Define a custom contains test for the artist.
The provided callable replaces the default
contains
method of the artist.Parameters: - pickercallable
A custom picker function to evaluate if an event is within the artist. The function must have the signature:
def contains(artist: Artist, event: MouseEvent) -> bool, dict
that returns:
- a bool indicating if the event is within the artist
- a dict of additional information. The dict should at least
return the same information as the default
contains()
implementation of the respective artist, but may provide additional information.
Notes
Deprecated since version 3.3.
-
set_dashes
(ls)¶ Alias for
set_linestyle
.
-
set_ec
(c)¶ Alias for
set_edgecolor
.
-
set_edgecolor
(c)¶ Set the edgecolor(s) of the collection.
Parameters: - ccolor or list of colors or 'face'
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
-
set_edgecolors
(c)¶ Alias for
set_edgecolor
.
-
set_facecolor
(c)¶ Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Parameters: - ccolor or list of colors
-
set_facecolors
(c)¶ Alias for
set_facecolor
.
-
set_fc
(c)¶ Alias for
set_facecolor
.
-
set_gid
(gid)¶ Set the (group) id for the artist.
Parameters: - gidstr
-
set_hatch
(hatch)¶ Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Parameters: - hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
-
set_in_layout
(in_layout)¶ Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.Parameters: - in_layoutbool
-
set_joinstyle
(js)¶ Set the joinstyle for the collection (for all its elements).
Parameters: - js{'miter', 'round', 'bevel'}
The joinstyle.
-
set_label
(s)¶ Set a label that will be displayed in the legend.
Parameters: - sobject
s will be converted to a string by calling
str
.
-
set_linestyle
(ls)¶ Set the linestyle(s) for the collection.
linestyle description '-'
or'solid'
solid line '--'
or'dashed'
dashed line '-.'
or'dashdot'
dash-dotted line ':'
or'dotted'
dotted line Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.Parameters: - lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for a complete description.
-
set_linestyles
(ls)¶ Alias for
set_linestyle
.
-
set_linewidth
(lw)¶ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Parameters: - lwfloat or list of floats
-
set_linewidths
(lw)¶ Alias for
set_linewidth
.
-
set_ls
(ls)¶ Alias for
set_linestyle
.
-
set_lw
(lw)¶ Alias for
set_linewidth
.
-
set_norm
(norm)¶ Set the normalization instance.
Parameters: - norm
Normalize
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.
- norm
-
set_offset_position
(offset_position)¶ [Deprecated] Set how offsets are applied. If offset_position is 'screen' (default) the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Parameters: - offset_position{'screen', 'data'}
Notes
Deprecated since version 3.3.
-
set_offsets
(offsets)¶ Set the offsets for the collection.
Parameters: - offsetsarray-like (N, 2) or (2,)
-
set_path_effects
(path_effects)¶ Set the path effects.
Parameters: - path_effects
AbstractPathEffect
- path_effects
-
set_paths
()¶
-
set_picker
(picker)¶ Define the picking behavior of the artist.
Parameters: - pickerNone or bool or callable
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A 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.
deprecated: For
Line2D
only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. UseLine2D.set_pickradius
instead.
-
set_pickradius
(pr)¶ Set the pick radius used for containment tests.
Parameters: - dfloat
Pick radius, in points.
-
set_rasterized
(rasterized)¶ Force rasterized (bitmap) drawing in vector backend output.
Defaults to None, which implies the backend's default behavior.
Parameters: - rasterizedbool or None
-
set_sketch_params
(scale=None, length=None, randomness=None)¶ Sets the sketch parameters.
Parameters: - scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is
None
, or not provided, no sketch filter will be provided.- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
-
set_snap
(snap)¶ Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters: - snapbool or None
Possible values:
- True: Snap vertices to the nearest pixel center.
- False: Do not modify vertex positions.
- None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
-
set_url
(url)¶ Set the url for the artist.
Parameters: - urlstr
-
set_urls
(urls)¶ Parameters: - urlslist of str or None
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
-
set_visible
(b)¶ Set the artist's visibility.
Parameters: - bbool
-
set_zorder
(level)¶ Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters: - levelfloat
-
property
stale
¶ Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
-
property
sticky_edges
¶ x
andy
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.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
-
to_rgba
(x, alpha=None, bytes=False, norm=True)¶ Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
-
update
(props)¶ Update this artist's properties from the dict props.
Parameters: - propsdict
-
property
update_dict
¶
-
update_from
(other)¶ Copy properties from other to self.
-
update_scalarmappable
()¶ Update colors from the scalar mappable array, if it is not None.
-
zorder
= 0¶
-
class
matplotlib.collections.
EventCollection
(positions, orientation='horizontal', lineoffset=0, linelength=1, linewidth=None, color=None, linestyle='solid', antialiased=None, **kwargs)[source]¶ Bases:
matplotlib.collections.LineCollection
A collection of locations along a single axis at which an "event" occured.
The events are given by a 1-dimensional array. They do not have an amplitude and are displayed as parallel lines.
Parameters: - positions1D array-like
Each value is an event.
- orientation{'horizontal', 'vertical'}, default: 'horizontal'
The sequence of events is plotted along this direction. The marker lines of the single events are along the orthogonal direction.
- lineoffsetfloat, default: 0
The offset of the center of the markers from the origin, in the direction orthogonal to orientation.
- linelengthfloat, default: 1
The total height of the marker (i.e. the marker stretches from
lineoffset - linelength/2
tolineoffset + linelength/2
).- linewidthfloat or list thereof, default:
rcParams["lines.linewidth"]
(default:1.5
) The line width of the event lines, in points.
- colorcolor or list of colors, default:
rcParams["lines.color"]
(default:'C0'
) The color of the event lines.
- linestylestr or tuple or list thereof, default: 'solid'
Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:
(offset, onoffseq),
where onoffseq is an even length tuple of on and off ink in points.
- antialiasedbool or list thereof, default:
rcParams["lines.antialiased"]
(default:True
) Whether to use antialiasing for drawing the lines.
- **kwargs
Forwarded to
LineCollection
.
Examples
(Source code, png, pdf)
-
add_callback
(func)¶ Add a callback function that will be called whenever one of the
Artist
's properties changes.Parameters: - funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling
Artist
. Return values may exist but are ignored.
Returns: - int
The observer id associated with the callback. This id can be used for removing the callback with
remove_callback
later.
See also
-
add_checker
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
append_positions
(position)¶ Add one or more events at the specified positions.
-
autoscale
()¶ Autoscale the scalar limits on the norm instance using the current array
-
autoscale_None
()¶ Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
-
changed
()¶ Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
-
check_update
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
contains
(mouseevent)¶ Test whether the mouse event occurred in the collection.
Returns
bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
-
convert_xunits
(x)¶ Convert x using the unit type of the xaxis.
If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.
-
convert_yunits
(y)¶ Convert y using the unit type of the yaxis.
If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.
-
draw
(renderer)¶ Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visible
returns False).Parameters: - renderer
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
- renderer
-
extend_positions
(position)¶ Add one or more events at the specified positions.
-
findobj
(match=None, include_self=True)¶ Find artist objects.
Recursively find all
Artist
instances contained in the artist.Parameters: - match
A filter criterion for the matches. This can be
- None: Return all objects contained in artist.
- A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True. - A class instance: e.g.,
Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
- include_selfbool
Include self in the list to be checked for a match.
Returns: - list of
Artist
-
format_cursor_data
(data)¶ 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.
See also
-
get_agg_filter
()¶ Return filter function to be used for agg filter.
-
get_alpha
()¶ Return the alpha value used for blending - not supported on all backends.
-
get_animated
()¶ Return whether the artist is animated.
-
get_array
()¶ Return the data array.
-
get_capstyle
()¶
-
get_clim
()¶ Return the values (min, max) that are mapped to the colormap limits.
-
get_clip_box
()¶ Return the clipbox.
-
get_clip_on
()¶ Return whether the artist uses clipping.
-
get_clip_path
()¶ Return the clip path.
-
get_colors
()¶
-
get_contains
()¶ [Deprecated] Return the custom contains function of the artist if set, or None.
See also
Notes
Deprecated since version 3.3.
-
get_cursor_data
(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.Parameters: See also
-
get_dashes
()¶ Alias for
get_linestyle
.
-
get_datalim
(transData)¶
-
get_ec
()¶ Alias for
get_edgecolor
.
-
get_edgecolor
()¶
-
get_edgecolors
()¶ Alias for
get_edgecolor
.
-
get_facecolor
()¶
-
get_facecolors
()¶ Alias for
get_facecolor
.
-
get_fc
()¶ Alias for
get_facecolor
.
-
get_fill
()¶ Return whether fill is set.
-
get_gid
()¶ Return the group id.
-
get_hatch
()¶ Return the current hatching pattern.
-
get_in_layout
()¶ Return boolean flag,
True
if artist is included in layout calculations.E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.
-
get_joinstyle
()¶
-
get_label
()¶ Return the label used for this artist in the legend.
-
get_linestyle
()¶
-
get_linestyles
()¶ Alias for
get_linestyle
.
-
get_linewidths
()[source]¶ Alias for
get_linewidth
.
-
get_ls
()¶ Alias for
get_linestyle
.
-
get_lw
()¶ Alias for
get_linewidth
.
-
get_offset_position
()¶ [Deprecated] Return how offsets are applied for the collection. If offset_position is 'screen', the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Notes
Deprecated since version 3.3.
-
get_offset_transform
()¶
-
get_offsets
()¶ Return the offsets for the collection.
-
get_path_effects
()¶
-
get_paths
()¶
-
get_picker
()¶ Return the picking behavior of the artist.
The possible values are described in
set_picker
.See also
-
get_pickradius
()¶
-
get_rasterized
()¶ Return whether the artist is to be rasterized.
-
get_segments
()¶ Returns: - list
List of segments in the LineCollection. Each list item contains an array of vertices.
-
get_sketch_params
()¶ Return the sketch parameters for the artist.
Returns: - tuple or None
A 3-tuple with the following elements:
- scale: The amplitude of the wiggle perpendicular to the source line.
- length: The length of the wiggle along the line.
- randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
-
get_tightbbox
(renderer)¶ Like
Artist.get_window_extent
, but includes any clipping.Parameters: - renderer
RendererBase
subclass renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
Returns: Bbox
The enclosing bounding box (in figure pixel coordinates).
- renderer
-
get_transformed_clip_path_and_affine
()¶ Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
-
get_transforms
()¶
-
get_url
()¶ Return the url.
-
get_urls
()¶ Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
-
get_visible
()¶ Return the visibility.
-
get_window_extent
(renderer)¶ Get the axes bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
-
get_zorder
()¶ Return the artist's zorder.
-
have_units
()¶ Return True if units are set on any axis.
-
is_transform_set
()¶ Return whether the Artist has an explicitly set transform.
This is True after
set_transform
has been called.
-
property
mouseover
¶ If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also
get_cursor_data()
,ToolCursorPosition
andNavigationToolbar2
.
-
pchanged
()¶ Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
-
pick
(mouseevent)¶ Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
-
pickable
()¶ Return whether the artist is pickable.
See also
-
properties
()¶ Return a dictionary of all the properties of the artist.
-
remove
()¶ Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with
FigureCanvasBase.draw_idle
. Callrelim
to update the axes limits if desired.Note:
relim
will not see collections even if the collection was added to the axes with autolim = True.Note: there is no support for removing the artist's legend entry.
-
remove_callback
(oid)¶ Remove a callback based on its observer id.
See also
-
set
(**kwargs)¶ A property batch setter. Pass kwargs to set properties.
-
set_aa
(aa)¶ Alias for
set_antialiased
.
-
set_agg_filter
(filter_func)¶ Set the agg filter.
Parameters: - filter_funccallable
A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.
-
set_alpha
(alpha)¶ Set the alpha value used for blending - not supported on all backends.
Parameters: - alphafloat or None
-
set_animated
(b)¶ Set the artist's animation state.
Parameters: - bbool
-
set_antialiased
(aa)¶ Set the antialiasing state for rendering.
Parameters: - aabool or list of bools
-
set_antialiaseds
(aa)¶ Alias for
set_antialiased
.
-
set_array
(A)¶ Set the image array from numpy array A.
Parameters: - Andarray
-
set_capstyle
(cs)¶ Set the capstyle for the collection (for all its elements).
Parameters: - cs{'butt', 'round', 'projecting'}
The capstyle.
-
set_clim
(vmin=None, vmax=None)¶ Set the norm limits for image scaling.
Parameters: - vmin, vmaxfloat
The limits.
The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
-
set_clip_on
(b)¶ Set whether the artist uses clipping.
When False artists will be visible outside of the axes which can lead to unexpected results.
Parameters: - bbool
-
set_clip_path
(path, transform=None)¶ Set the artist's clip path.
Parameters: - path
Patch
orPath
orTransformedPath
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
Transform
, optional Only used if path is a
Path
, in which case the givenPath
is converted to aTransformedPath
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 toNone
.For technical reasons (support of
set
), a tuple (path, transform) is also accepted as a single positional parameter.- path
-
set_color
(c)¶ Set the color(s) of the LineCollection.
Parameters: - ccolor or list of colors
Single color (all patches have same color), or a sequence of rgba tuples; if it is a sequence the patches will cycle through the sequence.
-
set_contains
(picker)¶ [Deprecated] Define a custom contains test for the artist.
The provided callable replaces the default
contains
method of the artist.Parameters: - pickercallable
A custom picker function to evaluate if an event is within the artist. The function must have the signature:
def contains(artist: Artist, event: MouseEvent) -> bool, dict
that returns:
- a bool indicating if the event is within the artist
- a dict of additional information. The dict should at least
return the same information as the default
contains()
implementation of the respective artist, but may provide additional information.
Notes
Deprecated since version 3.3.
-
set_dashes
(ls)¶ Alias for
set_linestyle
.
-
set_ec
(c)¶ Alias for
set_edgecolor
.
-
set_edgecolor
(c)¶ Set the edgecolor(s) of the collection.
Parameters: - ccolor or list of colors or 'face'
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
-
set_edgecolors
(c)¶ Alias for
set_edgecolor
.
-
set_facecolor
(c)¶ Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Parameters: - ccolor or list of colors
-
set_facecolors
(c)¶ Alias for
set_facecolor
.
-
set_fc
(c)¶ Alias for
set_facecolor
.
-
set_gid
(gid)¶ Set the (group) id for the artist.
Parameters: - gidstr
-
set_hatch
(hatch)¶ Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Parameters: - hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
-
set_in_layout
(in_layout)¶ Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.Parameters: - in_layoutbool
-
set_joinstyle
(js)¶ Set the joinstyle for the collection (for all its elements).
Parameters: - js{'miter', 'round', 'bevel'}
The joinstyle.
-
set_label
(s)¶ Set a label that will be displayed in the legend.
Parameters: - sobject
s will be converted to a string by calling
str
.
-
set_linestyle
(ls)¶ Set the linestyle(s) for the collection.
linestyle description '-'
or'solid'
solid line '--'
or'dashed'
dashed line '-.'
or'dashdot'
dash-dotted line ':'
or'dotted'
dotted line Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.Parameters: - lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for a complete description.
-
set_linestyles
(ls)¶ Alias for
set_linestyle
.
-
set_linewidth
(lw)¶ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Parameters: - lwfloat or list of floats
-
set_linewidths
(lw)¶ Alias for
set_linewidth
.
-
set_ls
(ls)¶ Alias for
set_linestyle
.
-
set_lw
(lw)¶ Alias for
set_linewidth
.
-
set_norm
(norm)¶ Set the normalization instance.
Parameters: - norm
Normalize
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.
- norm
-
set_offset_position
(offset_position)¶ [Deprecated] Set how offsets are applied. If offset_position is 'screen' (default) the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Parameters: - offset_position{'screen', 'data'}
Notes
Deprecated since version 3.3.
-
set_offsets
(offsets)¶ Set the offsets for the collection.
Parameters: - offsetsarray-like (N, 2) or (2,)
-
set_orientation
(orientation=None)[source]¶ Set the orientation of the event line.
Parameters: - orientation{'horizontal', 'vertical'}
-
set_path_effects
(path_effects)¶ Set the path effects.
Parameters: - path_effects
AbstractPathEffect
- path_effects
-
set_paths
(segments)¶
-
set_picker
(picker)¶ Define the picking behavior of the artist.
Parameters: - pickerNone or bool or callable
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A 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.
deprecated: For
Line2D
only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. UseLine2D.set_pickradius
instead.
-
set_pickradius
(pr)¶ Set the pick radius used for containment tests.
Parameters: - dfloat
Pick radius, in points.
-
set_rasterized
(rasterized)¶ Force rasterized (bitmap) drawing in vector backend output.
Defaults to None, which implies the backend's default behavior.
Parameters: - rasterizedbool or None
-
set_segments
(segments)¶
-
set_sketch_params
(scale=None, length=None, randomness=None)¶ Sets the sketch parameters.
Parameters: - scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is
None
, or not provided, no sketch filter will be provided.- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
-
set_snap
(snap)¶ Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters: - snapbool or None
Possible values:
- True: Snap vertices to the nearest pixel center.
- False: Do not modify vertex positions.
- None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
-
set_url
(url)¶ Set the url for the artist.
Parameters: - urlstr
-
set_urls
(urls)¶ Parameters: - urlslist of str or None
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
-
set_verts
(segments)¶
-
set_visible
(b)¶ Set the artist's visibility.
Parameters: - bbool
-
set_zorder
(level)¶ Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters: - levelfloat
-
property
stale
¶ Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
-
property
sticky_edges
¶ x
andy
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.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
-
switch_orientation
()[source]¶ Switch the orientation of the event line, either from vertical to horizontal or vice versus.
-
to_rgba
(x, alpha=None, bytes=False, norm=True)¶ Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
-
update
(props)¶ Update this artist's properties from the dict props.
Parameters: - propsdict
-
property
update_dict
¶
-
update_from
(other)¶ Copy properties from other to self.
-
update_scalarmappable
()¶ Update colors from the scalar mappable array, if it is not None.
-
zorder
= 0¶
-
class
matplotlib.collections.
LineCollection
(segments, linewidths=None, colors=None, antialiaseds=None, linestyles='solid', offsets=None, transOffset=None, norm=None, cmap=None, pickradius=5, zorder=2, facecolors='none', **kwargs)[source]¶ Bases:
matplotlib.collections.Collection
Represents a sequence of
Line2D
s that should be drawn together.This class extends
Collection
to represent a sequence ofLine2D
s instead of just a sequence ofPatch
s. Just as inCollection
, each property of 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 thei
th element of the collection is:prop[i % len(prop)]
The properties of each member of a LineCollection default to their values in
rcParams["lines.*"]
instead ofrcParams["patch.*"]
, and the property colors is added in place of edgecolors.Parameters: - segments: list of array-like
A sequence of (line0, line1, line2), where:
linen = (x0, y0), (x1, y1), ... (xm, ym)
or the equivalent numpy array with two columns. Each line can have a different number of segments.
- linewidthsfloat or list of float, default:
rcParams["lines.linewidth"]
(default:1.5
) The width of each line in points.
- colorscolor or list of color, default:
rcParams["lines.color"]
(default:'C0'
) A sequence of RGBA tuples (e.g., arbitrary color strings, etc, not allowed).
- antialiasedsbool or list of bool, default:
rcParams["lines.antialiased"]
(default:True
) Whether to use antialiasing for each line.
- zorderint, default: 2
zorder of the lines once drawn.
- facecolorscolor or list of color, default: 'none'
The facecolors of the LineCollection. Setting to a value other than 'none' will lead to each line being "filled in" as if there was an implicit line segment joining the last and first points of that line back around to each other. 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 ofCLOSEPOLY
.- **kwargs
Forwareded to
Collection
.
-
add_callback
(func)¶ Add a callback function that will be called whenever one of the
Artist
's properties changes.Parameters: - funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling
Artist
. Return values may exist but are ignored.
Returns: - int
The observer id associated with the callback. This id can be used for removing the callback with
remove_callback
later.
See also
-
add_checker
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
autoscale
()¶ Autoscale the scalar limits on the norm instance using the current array
-
autoscale_None
()¶ Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
-
changed
()¶ Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
-
check_update
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
contains
(mouseevent)¶ Test whether the mouse event occurred in the collection.
Returns
bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
-
convert_xunits
(x)¶ Convert x using the unit type of the xaxis.
If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.
-
convert_yunits
(y)¶ Convert y using the unit type of the yaxis.
If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.
-
draw
(renderer)¶ Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visible
returns False).Parameters: - renderer
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
- renderer
-
findobj
(match=None, include_self=True)¶ Find artist objects.
Recursively find all
Artist
instances contained in the artist.Parameters: - match
A filter criterion for the matches. This can be
- None: Return all objects contained in artist.
- A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True. - A class instance: e.g.,
Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
- include_selfbool
Include self in the list to be checked for a match.
Returns: - list of
Artist
-
format_cursor_data
(data)¶ 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.
See also
-
get_agg_filter
()¶ Return filter function to be used for agg filter.
-
get_alpha
()¶ Return the alpha value used for blending - not supported on all backends.
-
get_animated
()¶ Return whether the artist is animated.
-
get_array
()¶ Return the data array.
-
get_capstyle
()¶
-
get_clim
()¶ Return the values (min, max) that are mapped to the colormap limits.
-
get_clip_box
()¶ Return the clipbox.
-
get_clip_on
()¶ Return whether the artist uses clipping.
-
get_clip_path
()¶ Return the clip path.
-
get_colors
()¶
-
get_contains
()¶ [Deprecated] Return the custom contains function of the artist if set, or None.
See also
Notes
Deprecated since version 3.3.
-
get_cursor_data
(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.Parameters: See also
-
get_dashes
()¶ Alias for
get_linestyle
.
-
get_datalim
(transData)¶
-
get_ec
()¶ Alias for
get_edgecolor
.
-
get_edgecolor
()¶
-
get_edgecolors
()¶ Alias for
get_edgecolor
.
-
get_facecolor
()¶
-
get_facecolors
()¶ Alias for
get_facecolor
.
-
get_fc
()¶ Alias for
get_facecolor
.
-
get_fill
()¶ Return whether fill is set.
-
get_gid
()¶ Return the group id.
-
get_hatch
()¶ Return the current hatching pattern.
-
get_in_layout
()¶ Return boolean flag,
True
if artist is included in layout calculations.E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.
-
get_joinstyle
()¶
-
get_label
()¶ Return the label used for this artist in the legend.
-
get_linestyle
()¶
-
get_linestyles
()¶ Alias for
get_linestyle
.
-
get_linewidth
()¶
-
get_linewidths
()¶ Alias for
get_linewidth
.
-
get_ls
()¶ Alias for
get_linestyle
.
-
get_lw
()¶ Alias for
get_linewidth
.
-
get_offset_position
()¶ [Deprecated] Return how offsets are applied for the collection. If offset_position is 'screen', the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Notes
Deprecated since version 3.3.
-
get_offset_transform
()¶
-
get_offsets
()¶ Return the offsets for the collection.
-
get_path_effects
()¶
-
get_paths
()¶
-
get_picker
()¶ Return the picking behavior of the artist.
The possible values are described in
set_picker
.See also
-
get_pickradius
()¶
-
get_rasterized
()¶ Return whether the artist is to be rasterized.
-
get_segments
()[source]¶ Returns: - list
List of segments in the LineCollection. Each list item contains an array of vertices.
-
get_sketch_params
()¶ Return the sketch parameters for the artist.
Returns: - tuple or None
A 3-tuple with the following elements:
- scale: The amplitude of the wiggle perpendicular to the source line.
- length: The length of the wiggle along the line.
- randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
-
get_tightbbox
(renderer)¶ Like
Artist.get_window_extent
, but includes any clipping.Parameters: - renderer
RendererBase
subclass renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
Returns: Bbox
The enclosing bounding box (in figure pixel coordinates).
- renderer
-
get_transformed_clip_path_and_affine
()¶ Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
-
get_transforms
()¶
-
get_url
()¶ Return the url.
-
get_urls
()¶ Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
-
get_visible
()¶ Return the visibility.
-
get_window_extent
(renderer)¶ Get the axes bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
-
get_zorder
()¶ Return the artist's zorder.
-
have_units
()¶ Return True if units are set on any axis.
-
is_transform_set
()¶ Return whether the Artist has an explicitly set transform.
This is True after
set_transform
has been called.
-
property
mouseover
¶ If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also
get_cursor_data()
,ToolCursorPosition
andNavigationToolbar2
.
-
pchanged
()¶ Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
-
pick
(mouseevent)¶ Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
-
pickable
()¶ Return whether the artist is pickable.
See also
-
properties
()¶ Return a dictionary of all the properties of the artist.
-
remove
()¶ Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with
FigureCanvasBase.draw_idle
. Callrelim
to update the axes limits if desired.Note:
relim
will not see collections even if the collection was added to the axes with autolim = True.Note: there is no support for removing the artist's legend entry.
-
remove_callback
(oid)¶ Remove a callback based on its observer id.
See also
-
set
(**kwargs)¶ A property batch setter. Pass kwargs to set properties.
-
set_aa
(aa)¶ Alias for
set_antialiased
.
-
set_agg_filter
(filter_func)¶ Set the agg filter.
Parameters: - filter_funccallable
A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.
-
set_alpha
(alpha)¶ Set the alpha value used for blending - not supported on all backends.
Parameters: - alphafloat or None
-
set_animated
(b)¶ Set the artist's animation state.
Parameters: - bbool
-
set_antialiased
(aa)¶ Set the antialiasing state for rendering.
Parameters: - aabool or list of bools
-
set_antialiaseds
(aa)¶ Alias for
set_antialiased
.
-
set_array
(A)¶ Set the image array from numpy array A.
Parameters: - Andarray
-
set_capstyle
(cs)¶ Set the capstyle for the collection (for all its elements).
Parameters: - cs{'butt', 'round', 'projecting'}
The capstyle.
-
set_clim
(vmin=None, vmax=None)¶ Set the norm limits for image scaling.
Parameters: - vmin, vmaxfloat
The limits.
The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
-
set_clip_on
(b)¶ Set whether the artist uses clipping.
When False artists will be visible outside of the axes which can lead to unexpected results.
Parameters: - bbool
-
set_clip_path
(path, transform=None)¶ Set the artist's clip path.
Parameters: - path
Patch
orPath
orTransformedPath
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
Transform
, optional Only used if path is a
Path
, in which case the givenPath
is converted to aTransformedPath
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 toNone
.For technical reasons (support of
set
), a tuple (path, transform) is also accepted as a single positional parameter.- path
-
set_color
(c)[source]¶ Set the color(s) of the LineCollection.
Parameters: - ccolor or list of colors
Single color (all patches have same color), or a sequence of rgba tuples; if it is a sequence the patches will cycle through the sequence.
-
set_contains
(picker)¶ [Deprecated] Define a custom contains test for the artist.
The provided callable replaces the default
contains
method of the artist.Parameters: - pickercallable
A custom picker function to evaluate if an event is within the artist. The function must have the signature:
def contains(artist: Artist, event: MouseEvent) -> bool, dict
that returns:
- a bool indicating if the event is within the artist
- a dict of additional information. The dict should at least
return the same information as the default
contains()
implementation of the respective artist, but may provide additional information.
Notes
Deprecated since version 3.3.
-
set_dashes
(ls)¶ Alias for
set_linestyle
.
-
set_ec
(c)¶ Alias for
set_edgecolor
.
-
set_edgecolor
(c)¶ Set the edgecolor(s) of the collection.
Parameters: - ccolor or list of colors or 'face'
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
-
set_edgecolors
(c)¶ Alias for
set_edgecolor
.
-
set_facecolor
(c)¶ Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Parameters: - ccolor or list of colors
-
set_facecolors
(c)¶ Alias for
set_facecolor
.
-
set_fc
(c)¶ Alias for
set_facecolor
.
-
set_gid
(gid)¶ Set the (group) id for the artist.
Parameters: - gidstr
-
set_hatch
(hatch)¶ Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Parameters: - hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
-
set_in_layout
(in_layout)¶ Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.Parameters: - in_layoutbool
-
set_joinstyle
(js)¶ Set the joinstyle for the collection (for all its elements).
Parameters: - js{'miter', 'round', 'bevel'}
The joinstyle.
-
set_label
(s)¶ Set a label that will be displayed in the legend.
Parameters: - sobject
s will be converted to a string by calling
str
.
-
set_linestyle
(ls)¶ Set the linestyle(s) for the collection.
linestyle description '-'
or'solid'
solid line '--'
or'dashed'
dashed line '-.'
or'dashdot'
dash-dotted line ':'
or'dotted'
dotted line Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.Parameters: - lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for a complete description.
-
set_linestyles
(ls)¶ Alias for
set_linestyle
.
-
set_linewidth
(lw)¶ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Parameters: - lwfloat or list of floats
-
set_linewidths
(lw)¶ Alias for
set_linewidth
.
-
set_ls
(ls)¶ Alias for
set_linestyle
.
-
set_lw
(lw)¶ Alias for
set_linewidth
.
-
set_norm
(norm)¶ Set the normalization instance.
Parameters: - norm
Normalize
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.
- norm
-
set_offset_position
(offset_position)¶ [Deprecated] Set how offsets are applied. If offset_position is 'screen' (default) the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Parameters: - offset_position{'screen', 'data'}
Notes
Deprecated since version 3.3.
-
set_offsets
(offsets)¶ Set the offsets for the collection.
Parameters: - offsetsarray-like (N, 2) or (2,)
-
set_path_effects
(path_effects)¶ Set the path effects.
Parameters: - path_effects
AbstractPathEffect
- path_effects
-
set_paths
(segments)¶
-
set_picker
(picker)¶ Define the picking behavior of the artist.
Parameters: - pickerNone or bool or callable
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A 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.
deprecated: For
Line2D
only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. UseLine2D.set_pickradius
instead.
-
set_pickradius
(pr)¶ Set the pick radius used for containment tests.
Parameters: - dfloat
Pick radius, in points.
-
set_rasterized
(rasterized)¶ Force rasterized (bitmap) drawing in vector backend output.
Defaults to None, which implies the backend's default behavior.
Parameters: - rasterizedbool or None
-
set_sketch_params
(scale=None, length=None, randomness=None)¶ Sets the sketch parameters.
Parameters: - scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is
None
, or not provided, no sketch filter will be provided.- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
-
set_snap
(snap)¶ Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters: - snapbool or None
Possible values:
- True: Snap vertices to the nearest pixel center.
- False: Do not modify vertex positions.
- None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
-
set_url
(url)¶ Set the url for the artist.
Parameters: - urlstr
-
set_urls
(urls)¶ Parameters: - urlslist of str or None
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
-
set_verts
(segments)¶
-
set_visible
(b)¶ Set the artist's visibility.
Parameters: - bbool
-
set_zorder
(level)¶ Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters: - levelfloat
-
property
stale
¶ Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
-
property
sticky_edges
¶ x
andy
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.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
-
to_rgba
(x, alpha=None, bytes=False, norm=True)¶ Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
-
update
(props)¶ Update this artist's properties from the dict props.
Parameters: - propsdict
-
property
update_dict
¶
-
update_from
(other)¶ Copy properties from other to self.
-
update_scalarmappable
()¶ Update colors from the scalar mappable array, if it is not None.
-
zorder
= 0¶
-
class
matplotlib.collections.
PatchCollection
(patches, match_original=False, **kwargs)[source]¶ Bases:
matplotlib.collections.Collection
A generic collection of patches.
This makes it easier to assign a color map to a heterogeneous collection of patches.
This also may improve plotting speed, since PatchCollection will draw faster than a large number of patches.
- patches
- a sequence of Patch objects. This list may include a heterogeneous assortment of different patch types.
- match_original
- If True, use the colors and linewidths of the original patches. If False, new colors may be assigned by providing the standard collection arguments, facecolor, edgecolor, linewidths, norm or cmap.
If any of edgecolors, facecolors, linewidths, antialiaseds are None, they default to their
rcParams
patch setting, in sequence form.The use of
ScalarMappable
functionality is optional. If theScalarMappable
matrix_A
has been set (via a call toset_array
), at draw time a call to scalar mappable will be made to set the face colors.-
add_callback
(func)¶ Add a callback function that will be called whenever one of the
Artist
's properties changes.Parameters: - funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling
Artist
. Return values may exist but are ignored.
Returns: - int
The observer id associated with the callback. This id can be used for removing the callback with
remove_callback
later.
See also
-
add_checker
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
autoscale
()¶ Autoscale the scalar limits on the norm instance using the current array
-
autoscale_None
()¶ Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
-
changed
()¶ Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
-
check_update
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
contains
(mouseevent)¶ Test whether the mouse event occurred in the collection.
Returns
bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
-
convert_xunits
(x)¶ Convert x using the unit type of the xaxis.
If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.
-
convert_yunits
(y)¶ Convert y using the unit type of the yaxis.
If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.
-
draw
(renderer)¶ Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visible
returns False).Parameters: - renderer
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
- renderer
-
findobj
(match=None, include_self=True)¶ Find artist objects.
Recursively find all
Artist
instances contained in the artist.Parameters: - match
A filter criterion for the matches. This can be
- None: Return all objects contained in artist.
- A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True. - A class instance: e.g.,
Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
- include_selfbool
Include self in the list to be checked for a match.
Returns: - list of
Artist
-
format_cursor_data
(data)¶ 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.
See also
-
get_agg_filter
()¶ Return filter function to be used for agg filter.
-
get_alpha
()¶ Return the alpha value used for blending - not supported on all backends.
-
get_animated
()¶ Return whether the artist is animated.
-
get_array
()¶ Return the data array.
-
get_capstyle
()¶
-
get_clim
()¶ Return the values (min, max) that are mapped to the colormap limits.
-
get_clip_box
()¶ Return the clipbox.
-
get_clip_on
()¶ Return whether the artist uses clipping.
-
get_clip_path
()¶ Return the clip path.
-
get_contains
()¶ [Deprecated] Return the custom contains function of the artist if set, or None.
See also
Notes
Deprecated since version 3.3.
-
get_cursor_data
(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.Parameters: See also
-
get_dashes
()¶ Alias for
get_linestyle
.
-
get_datalim
(transData)¶
-
get_ec
()¶ Alias for
get_edgecolor
.
-
get_edgecolor
()¶
-
get_edgecolors
()¶ Alias for
get_edgecolor
.
-
get_facecolor
()¶
-
get_facecolors
()¶ Alias for
get_facecolor
.
-
get_fc
()¶ Alias for
get_facecolor
.
-
get_fill
()¶ Return whether fill is set.
-
get_gid
()¶ Return the group id.
-
get_hatch
()¶ Return the current hatching pattern.
-
get_in_layout
()¶ Return boolean flag,
True
if artist is included in layout calculations.E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.
-
get_joinstyle
()¶
-
get_label
()¶ Return the label used for this artist in the legend.
-
get_linestyle
()¶
-
get_linestyles
()¶ Alias for
get_linestyle
.
-
get_linewidth
()¶
-
get_linewidths
()¶ Alias for
get_linewidth
.
-
get_ls
()¶ Alias for
get_linestyle
.
-
get_lw
()¶ Alias for
get_linewidth
.
-
get_offset_position
()¶ [Deprecated] Return how offsets are applied for the collection. If offset_position is 'screen', the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Notes
Deprecated since version 3.3.
-
get_offset_transform
()¶
-
get_offsets
()¶ Return the offsets for the collection.
-
get_path_effects
()¶
-
get_paths
()¶
-
get_picker
()¶ Return the picking behavior of the artist.
The possible values are described in
set_picker
.See also
-
get_pickradius
()¶
-
get_rasterized
()¶ Return whether the artist is to be rasterized.
-
get_sketch_params
()¶ Return the sketch parameters for the artist.
Returns: - tuple or None
A 3-tuple with the following elements:
- scale: The amplitude of the wiggle perpendicular to the source line.
- length: The length of the wiggle along the line.
- randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
-
get_tightbbox
(renderer)¶ Like
Artist.get_window_extent
, but includes any clipping.Parameters: - renderer
RendererBase
subclass renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
Returns: Bbox
The enclosing bounding box (in figure pixel coordinates).
- renderer
-
get_transformed_clip_path_and_affine
()¶ Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
-
get_transforms
()¶
-
get_url
()¶ Return the url.
-
get_urls
()¶ Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
-
get_visible
()¶ Return the visibility.
-
get_window_extent
(renderer)¶ Get the axes bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
-
get_zorder
()¶ Return the artist's zorder.
-
have_units
()¶ Return True if units are set on any axis.
-
is_transform_set
()¶ Return whether the Artist has an explicitly set transform.
This is True after
set_transform
has been called.
-
property
mouseover
¶ If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also
get_cursor_data()
,ToolCursorPosition
andNavigationToolbar2
.
-
pchanged
()¶ Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
-
pick
(mouseevent)¶ Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
-
pickable
()¶ Return whether the artist is pickable.
See also
-
properties
()¶ Return a dictionary of all the properties of the artist.
-
remove
()¶ Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with
FigureCanvasBase.draw_idle
. Callrelim
to update the axes limits if desired.Note:
relim
will not see collections even if the collection was added to the axes with autolim = True.Note: there is no support for removing the artist's legend entry.
-
remove_callback
(oid)¶ Remove a callback based on its observer id.
See also
-
set
(**kwargs)¶ A property batch setter. Pass kwargs to set properties.
-
set_aa
(aa)¶ Alias for
set_antialiased
.
-
set_agg_filter
(filter_func)¶ Set the agg filter.
Parameters: - filter_funccallable
A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.
-
set_alpha
(alpha)¶ Set the alpha value used for blending - not supported on all backends.
Parameters: - alphafloat or None
-
set_animated
(b)¶ Set the artist's animation state.
Parameters: - bbool
-
set_antialiased
(aa)¶ Set the antialiasing state for rendering.
Parameters: - aabool or list of bools
-
set_antialiaseds
(aa)¶ Alias for
set_antialiased
.
-
set_array
(A)¶ Set the image array from numpy array A.
Parameters: - Andarray
-
set_capstyle
(cs)¶ Set the capstyle for the collection (for all its elements).
Parameters: - cs{'butt', 'round', 'projecting'}
The capstyle.
-
set_clim
(vmin=None, vmax=None)¶ Set the norm limits for image scaling.
Parameters: - vmin, vmaxfloat
The limits.
The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
-
set_clip_on
(b)¶ Set whether the artist uses clipping.
When False artists will be visible outside of the axes which can lead to unexpected results.
Parameters: - bbool
-
set_clip_path
(path, transform=None)¶ Set the artist's clip path.
Parameters: - path
Patch
orPath
orTransformedPath
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
Transform
, optional Only used if path is a
Path
, in which case the givenPath
is converted to aTransformedPath
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 toNone
.For technical reasons (support of
set
), a tuple (path, transform) is also accepted as a single positional parameter.- path
-
set_color
(c)¶ Set both the edgecolor and the facecolor.
Parameters: - ccolor or list of rgba tuples
See also
Collection.set_facecolor
,Collection.set_edgecolor
- For setting the edge or face color individually.
-
set_contains
(picker)¶ [Deprecated] Define a custom contains test for the artist.
The provided callable replaces the default
contains
method of the artist.Parameters: - pickercallable
A custom picker function to evaluate if an event is within the artist. The function must have the signature:
def contains(artist: Artist, event: MouseEvent) -> bool, dict
that returns:
- a bool indicating if the event is within the artist
- a dict of additional information. The dict should at least
return the same information as the default
contains()
implementation of the respective artist, but may provide additional information.
Notes
Deprecated since version 3.3.
-
set_dashes
(ls)¶ Alias for
set_linestyle
.
-
set_ec
(c)¶ Alias for
set_edgecolor
.
-
set_edgecolor
(c)¶ Set the edgecolor(s) of the collection.
Parameters: - ccolor or list of colors or 'face'
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
-
set_edgecolors
(c)¶ Alias for
set_edgecolor
.
-
set_facecolor
(c)¶ Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Parameters: - ccolor or list of colors
-
set_facecolors
(c)¶ Alias for
set_facecolor
.
-
set_fc
(c)¶ Alias for
set_facecolor
.
-
set_gid
(gid)¶ Set the (group) id for the artist.
Parameters: - gidstr
-
set_hatch
(hatch)¶ Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Parameters: - hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
-
set_in_layout
(in_layout)¶ Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.Parameters: - in_layoutbool
-
set_joinstyle
(js)¶ Set the joinstyle for the collection (for all its elements).
Parameters: - js{'miter', 'round', 'bevel'}
The joinstyle.
-
set_label
(s)¶ Set a label that will be displayed in the legend.
Parameters: - sobject
s will be converted to a string by calling
str
.
-
set_linestyle
(ls)¶ Set the linestyle(s) for the collection.
linestyle description '-'
or'solid'
solid line '--'
or'dashed'
dashed line '-.'
or'dashdot'
dash-dotted line ':'
or'dotted'
dotted line Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.Parameters: - lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for a complete description.
-
set_linestyles
(ls)¶ Alias for
set_linestyle
.
-
set_linewidth
(lw)¶ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Parameters: - lwfloat or list of floats
-
set_linewidths
(lw)¶ Alias for
set_linewidth
.
-
set_ls
(ls)¶ Alias for
set_linestyle
.
-
set_lw
(lw)¶ Alias for
set_linewidth
.
-
set_norm
(norm)¶ Set the normalization instance.
Parameters: - norm
Normalize
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.
- norm
-
set_offset_position
(offset_position)¶ [Deprecated] Set how offsets are applied. If offset_position is 'screen' (default) the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Parameters: - offset_position{'screen', 'data'}
Notes
Deprecated since version 3.3.
-
set_offsets
(offsets)¶ Set the offsets for the collection.
Parameters: - offsetsarray-like (N, 2) or (2,)
-
set_path_effects
(path_effects)¶ Set the path effects.
Parameters: - path_effects
AbstractPathEffect
- path_effects
-
set_picker
(picker)¶ Define the picking behavior of the artist.
Parameters: - pickerNone or bool or callable
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A 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.
deprecated: For
Line2D
only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. UseLine2D.set_pickradius
instead.
-
set_pickradius
(pr)¶ Set the pick radius used for containment tests.
Parameters: - dfloat
Pick radius, in points.
-
set_rasterized
(rasterized)¶ Force rasterized (bitmap) drawing in vector backend output.
Defaults to None, which implies the backend's default behavior.
Parameters: - rasterizedbool or None
-
set_sketch_params
(scale=None, length=None, randomness=None)¶ Sets the sketch parameters.
Parameters: - scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is
None
, or not provided, no sketch filter will be provided.- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
-
set_snap
(snap)¶ Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters: - snapbool or None
Possible values:
- True: Snap vertices to the nearest pixel center.
- False: Do not modify vertex positions.
- None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
-
set_url
(url)¶ Set the url for the artist.
Parameters: - urlstr
-
set_urls
(urls)¶ Parameters: - urlslist of str or None
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
-
set_visible
(b)¶ Set the artist's visibility.
Parameters: - bbool
-
set_zorder
(level)¶ Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters: - levelfloat
-
property
stale
¶ Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
-
property
sticky_edges
¶ x
andy
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.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
-
to_rgba
(x, alpha=None, bytes=False, norm=True)¶ Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
-
update
(props)¶ Update this artist's properties from the dict props.
Parameters: - propsdict
-
property
update_dict
¶
-
update_from
(other)¶ Copy properties from other to self.
-
update_scalarmappable
()¶ Update colors from the scalar mappable array, if it is not None.
-
zorder
= 0¶
-
class
matplotlib.collections.
PathCollection
(paths, sizes=None, **kwargs)[source]¶ Bases:
matplotlib.collections._CollectionWithSizes
A collection of
Path
s, as created by e.g.scatter
.Parameters: - pathslist of
path.Path
The paths that will make up the
Collection
.- sizesarray-like
The factor by which to scale each drawn
Path
. One unit squared in the Path's data space is scaled to besizes**2
points when rendered.- **kwargs
Forwarded to
Collection
.
-
add_callback
(func)¶ Add a callback function that will be called whenever one of the
Artist
's properties changes.Parameters: - funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling
Artist
. Return values may exist but are ignored.
Returns: - int
The observer id associated with the callback. This id can be used for removing the callback with
remove_callback
later.
See also
-
add_checker
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
autoscale
()¶ Autoscale the scalar limits on the norm instance using the current array
-
autoscale_None
()¶ Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
-
changed
()¶ Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
-
check_update
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
contains
(mouseevent)¶ Test whether the mouse event occurred in the collection.
Returns
bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
-
convert_xunits
(x)¶ Convert x using the unit type of the xaxis.
If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.
-
convert_yunits
(y)¶ Convert y using the unit type of the yaxis.
If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.
-
draw
(renderer)¶ Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visible
returns False).Parameters: - renderer
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
- renderer
-
findobj
(match=None, include_self=True)¶ Find artist objects.
Recursively find all
Artist
instances contained in the artist.Parameters: - match
A filter criterion for the matches. This can be
- None: Return all objects contained in artist.
- A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True. - A class instance: e.g.,
Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
- include_selfbool
Include self in the list to be checked for a match.
Returns: - list of
Artist
-
format_cursor_data
(data)¶ 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.
See also
-
get_agg_filter
()¶ Return filter function to be used for agg filter.
-
get_alpha
()¶ Return the alpha value used for blending - not supported on all backends.
-
get_animated
()¶ Return whether the artist is animated.
-
get_array
()¶ Return the data array.
-
get_capstyle
()¶
-
get_clim
()¶ Return the values (min, max) that are mapped to the colormap limits.
-
get_clip_box
()¶ Return the clipbox.
-
get_clip_on
()¶ Return whether the artist uses clipping.
-
get_clip_path
()¶ Return the clip path.
-
get_contains
()¶ [Deprecated] Return the custom contains function of the artist if set, or None.
See also
Notes
Deprecated since version 3.3.
-
get_cursor_data
(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.Parameters: See also
-
get_dashes
()¶ Alias for
get_linestyle
.
-
get_datalim
(transData)¶
-
get_ec
()¶ Alias for
get_edgecolor
.
-
get_edgecolor
()¶
-
get_edgecolors
()¶ Alias for
get_edgecolor
.
-
get_facecolor
()¶
-
get_facecolors
()¶ Alias for
get_facecolor
.
-
get_fc
()¶ Alias for
get_facecolor
.
-
get_fill
()¶ Return whether fill is set.
-
get_gid
()¶ Return the group id.
-
get_hatch
()¶ Return the current hatching pattern.
-
get_in_layout
()¶ Return boolean flag,
True
if artist is included in layout calculations.E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.
-
get_joinstyle
()¶
-
get_label
()¶ Return the label used for this artist in the legend.
-
get_linestyle
()¶
-
get_linestyles
()¶ Alias for
get_linestyle
.
-
get_linewidth
()¶
-
get_linewidths
()¶ Alias for
get_linewidth
.
-
get_ls
()¶ Alias for
get_linestyle
.
-
get_lw
()¶ Alias for
get_linewidth
.
-
get_offset_position
()¶ [Deprecated] Return how offsets are applied for the collection. If offset_position is 'screen', the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Notes
Deprecated since version 3.3.
-
get_offset_transform
()¶
-
get_offsets
()¶ Return the offsets for the collection.
-
get_path_effects
()¶
-
get_picker
()¶ Return the picking behavior of the artist.
The possible values are described in
set_picker
.See also
-
get_pickradius
()¶
-
get_rasterized
()¶ Return whether the artist is to be rasterized.
-
get_sizes
()¶ Return the sizes ('areas') of the elements in the collection.
Returns: - array
The 'area' of each element.
-
get_sketch_params
()¶ Return the sketch parameters for the artist.
Returns: - tuple or None
A 3-tuple with the following elements:
- scale: The amplitude of the wiggle perpendicular to the source line.
- length: The length of the wiggle along the line.
- randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
-
get_tightbbox
(renderer)¶ Like
Artist.get_window_extent
, but includes any clipping.Parameters: - renderer
RendererBase
subclass renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
Returns: Bbox
The enclosing bounding box (in figure pixel coordinates).
- renderer
-
get_transformed_clip_path_and_affine
()¶ Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
-
get_transforms
()¶
-
get_url
()¶ Return the url.
-
get_urls
()¶ Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
-
get_visible
()¶ Return the visibility.
-
get_window_extent
(renderer)¶ Get the axes bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
-
get_zorder
()¶ Return the artist's zorder.
-
have_units
()¶ Return True if units are set on any axis.
-
is_transform_set
()¶ Return whether the Artist has an explicitly set transform.
This is True after
set_transform
has been called.
-
legend_elements
(prop='colors', num='auto', fmt=None, func=<function PathCollection.<lambda>>, **kwargs)[source]¶ Create legend handles and labels for a PathCollection.
Each legend handle is a
Line2D
representing the Path that was drawn, and each label is a string what each Path represents.This is useful for obtaining a legend for a
scatter
plot; e.g.:scatter = plt.scatter([1, 2, 3], [4, 5, 6], c=[7, 2, 3]) plt.legend(*scatter.legend_elements())
creates three legend elements, one for each color with the numerical values passed to c as the labels.
Also see the Automated legend creation example.
Parameters: - prop{"colors", "sizes"}, default: "colors"
If "colors", the legend handles will show the different colors of the collection. If "sizes", the legend will show the different sizes. To set both, use kwargs to directly edit the
Line2D
properties.- numint, None, "auto" (default), array-like, or
Locator
, Target number of elements to create. If None, use all unique elements of the mappable array. If an integer, target to use num elements in the normed range. If "auto", try to determine which option better suits the nature of the data. The number of created elements may slightly deviate from num due to a
Locator
being used to find useful locations. If a list or array, use exactly those elements for the legend. Finally, aLocator
can be provided.- fmtstr,
Formatter
, or None (default) The format or formatter to use for the labels. If a string must be a valid input for a
StrMethodFormatter
. If None (the default), use aScalarFormatter
.- funcfunction, default lambda x: x
Function to calculate the labels. Often the size (or color) argument to
scatter
will have been pre-processed by the user using a functions = f(x)
to make the markers visible; e.g.size = np.log10(x)
. Providing the inverse of this function here allows that pre-processing to be inverted, so that the legend labels have the correct values; e.g.func = lambda x: 10**x
.- **kwargs
Allowed keyword arguments are color and size. E.g. it may be useful to set the color of the markers if prop="sizes" is used; similarly to set the size of the markers if prop="colors" is used. Any further parameters are passed onto the
Line2D
instance. This may be useful to e.g. specify a different markeredgecolor or alpha for the legend handles.
Returns: - handleslist of
Line2D
Visual representation of each element of the legend.
- labelslist of str
The string labels for elements of the legend.
-
property
mouseover
¶ If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also
get_cursor_data()
,ToolCursorPosition
andNavigationToolbar2
.
-
pchanged
()¶ Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
-
pick
(mouseevent)¶ Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
-
pickable
()¶ Return whether the artist is pickable.
See also
-
properties
()¶ Return a dictionary of all the properties of the artist.
-
remove
()¶ Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with
FigureCanvasBase.draw_idle
. Callrelim
to update the axes limits if desired.Note:
relim
will not see collections even if the collection was added to the axes with autolim = True.Note: there is no support for removing the artist's legend entry.
-
remove_callback
(oid)¶ Remove a callback based on its observer id.
See also
-
set
(**kwargs)¶ A property batch setter. Pass kwargs to set properties.
-
set_aa
(aa)¶ Alias for
set_antialiased
.
-
set_agg_filter
(filter_func)¶ Set the agg filter.
Parameters: - filter_funccallable
A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.
-
set_alpha
(alpha)¶ Set the alpha value used for blending - not supported on all backends.
Parameters: - alphafloat or None
-
set_animated
(b)¶ Set the artist's animation state.
Parameters: - bbool
-
set_antialiased
(aa)¶ Set the antialiasing state for rendering.
Parameters: - aabool or list of bools
-
set_antialiaseds
(aa)¶ Alias for
set_antialiased
.
-
set_array
(A)¶ Set the image array from numpy array A.
Parameters: - Andarray
-
set_capstyle
(cs)¶ Set the capstyle for the collection (for all its elements).
Parameters: - cs{'butt', 'round', 'projecting'}
The capstyle.
-
set_clim
(vmin=None, vmax=None)¶ Set the norm limits for image scaling.
Parameters: - vmin, vmaxfloat
The limits.
The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
-
set_clip_on
(b)¶ Set whether the artist uses clipping.
When False artists will be visible outside of the axes which can lead to unexpected results.
Parameters: - bbool
-
set_clip_path
(path, transform=None)¶ Set the artist's clip path.
Parameters: - path
Patch
orPath
orTransformedPath
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
Transform
, optional Only used if path is a
Path
, in which case the givenPath
is converted to aTransformedPath
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 toNone
.For technical reasons (support of
set
), a tuple (path, transform) is also accepted as a single positional parameter.- path
-
set_color
(c)¶ Set both the edgecolor and the facecolor.
Parameters: - ccolor or list of rgba tuples
See also
Collection.set_facecolor
,Collection.set_edgecolor
- For setting the edge or face color individually.
-
set_contains
(picker)¶ [Deprecated] Define a custom contains test for the artist.
The provided callable replaces the default
contains
method of the artist.Parameters: - pickercallable
A custom picker function to evaluate if an event is within the artist. The function must have the signature:
def contains(artist: Artist, event: MouseEvent) -> bool, dict
that returns:
- a bool indicating if the event is within the artist
- a dict of additional information. The dict should at least
return the same information as the default
contains()
implementation of the respective artist, but may provide additional information.
Notes
Deprecated since version 3.3.
-
set_dashes
(ls)¶ Alias for
set_linestyle
.
-
set_ec
(c)¶ Alias for
set_edgecolor
.
-
set_edgecolor
(c)¶ Set the edgecolor(s) of the collection.
Parameters: - ccolor or list of colors or 'face'
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
-
set_edgecolors
(c)¶ Alias for
set_edgecolor
.
-
set_facecolor
(c)¶ Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Parameters: - ccolor or list of colors
-
set_facecolors
(c)¶ Alias for
set_facecolor
.
-
set_fc
(c)¶ Alias for
set_facecolor
.
-
set_gid
(gid)¶ Set the (group) id for the artist.
Parameters: - gidstr
-
set_hatch
(hatch)¶ Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Parameters: - hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
-
set_in_layout
(in_layout)¶ Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.Parameters: - in_layoutbool
-
set_joinstyle
(js)¶ Set the joinstyle for the collection (for all its elements).
Parameters: - js{'miter', 'round', 'bevel'}
The joinstyle.
-
set_label
(s)¶ Set a label that will be displayed in the legend.
Parameters: - sobject
s will be converted to a string by calling
str
.
-
set_linestyle
(ls)¶ Set the linestyle(s) for the collection.
linestyle description '-'
or'solid'
solid line '--'
or'dashed'
dashed line '-.'
or'dashdot'
dash-dotted line ':'
or'dotted'
dotted line Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.Parameters: - lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for a complete description.
-
set_linestyles
(ls)¶ Alias for
set_linestyle
.
-
set_linewidth
(lw)¶ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Parameters: - lwfloat or list of floats
-
set_linewidths
(lw)¶ Alias for
set_linewidth
.
-
set_ls
(ls)¶ Alias for
set_linestyle
.
-
set_lw
(lw)¶ Alias for
set_linewidth
.
-
set_norm
(norm)¶ Set the normalization instance.
Parameters: - norm
Normalize
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.
- norm
-
set_offset_position
(offset_position)¶ [Deprecated] Set how offsets are applied. If offset_position is 'screen' (default) the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Parameters: - offset_position{'screen', 'data'}
Notes
Deprecated since version 3.3.
-
set_offsets
(offsets)¶ Set the offsets for the collection.
Parameters: - offsetsarray-like (N, 2) or (2,)
-
set_path_effects
(path_effects)¶ Set the path effects.
Parameters: - path_effects
AbstractPathEffect
- path_effects
-
set_picker
(picker)¶ Define the picking behavior of the artist.
Parameters: - pickerNone or bool or callable
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A 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.
deprecated: For
Line2D
only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. UseLine2D.set_pickradius
instead.
-
set_pickradius
(pr)¶ Set the pick radius used for containment tests.
Parameters: - dfloat
Pick radius, in points.
-
set_rasterized
(rasterized)¶ Force rasterized (bitmap) drawing in vector backend output.
Defaults to None, which implies the backend's default behavior.
Parameters: - rasterizedbool or None
-
set_sizes
(sizes, dpi=72.0)¶ Set the sizes of each member of the collection.
Parameters: - sizesndarray or None
The size to set for each element of the collection. The value is the 'area' of the element.
- dpifloat, default: 72
The dpi of the canvas.
-
set_sketch_params
(scale=None, length=None, randomness=None)¶ Sets the sketch parameters.
Parameters: - scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is
None
, or not provided, no sketch filter will be provided.- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
-
set_snap
(snap)¶ Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters: - snapbool or None
Possible values:
- True: Snap vertices to the nearest pixel center.
- False: Do not modify vertex positions.
- None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
-
set_url
(url)¶ Set the url for the artist.
Parameters: - urlstr
-
set_urls
(urls)¶ Parameters: - urlslist of str or None
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
-
set_visible
(b)¶ Set the artist's visibility.
Parameters: - bbool
-
set_zorder
(level)¶ Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters: - levelfloat
-
property
stale
¶ Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
-
property
sticky_edges
¶ x
andy
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.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
-
to_rgba
(x, alpha=None, bytes=False, norm=True)¶ Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
-
update
(props)¶ Update this artist's properties from the dict props.
Parameters: - propsdict
-
property
update_dict
¶
-
update_from
(other)¶ Copy properties from other to self.
-
update_scalarmappable
()¶ Update colors from the scalar mappable array, if it is not None.
-
zorder
= 0¶
- pathslist of
-
class
matplotlib.collections.
PolyCollection
(verts, sizes=None, closed=True, **kwargs)[source]¶ Bases:
matplotlib.collections._CollectionWithSizes
Parameters: - vertslist of array-like
The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).
- sizesarray-like, default: None
Squared scaling factors for the polygons. The coordinates of each polygon verts_i are multiplied by the square-root of the corresponding entry in sizes (i.e., sizes specify the scaling of areas). The scaling is applied before the Artist master transform.
- closedbool, default: True
Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.
- **kwargs
Forwarded to
Collection
.
-
add_callback
(func)¶ Add a callback function that will be called whenever one of the
Artist
's properties changes.Parameters: - funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling
Artist
. Return values may exist but are ignored.
Returns: - int
The observer id associated with the callback. This id can be used for removing the callback with
remove_callback
later.
See also
-
add_checker
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
autoscale
()¶ Autoscale the scalar limits on the norm instance using the current array
-
autoscale_None
()¶ Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
-
changed
()¶ Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
-
check_update
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
contains
(mouseevent)¶ Test whether the mouse event occurred in the collection.
Returns
bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
-
convert_xunits
(x)¶ Convert x using the unit type of the xaxis.
If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.
-
convert_yunits
(y)¶ Convert y using the unit type of the yaxis.
If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.
-
draw
(renderer)¶ Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visible
returns False).Parameters: - renderer
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
- renderer
-
findobj
(match=None, include_self=True)¶ Find artist objects.
Recursively find all
Artist
instances contained in the artist.Parameters: - match
A filter criterion for the matches. This can be
- None: Return all objects contained in artist.
- A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True. - A class instance: e.g.,
Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
- include_selfbool
Include self in the list to be checked for a match.
Returns: - list of
Artist
-
format_cursor_data
(data)¶ 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.
See also
-
get_agg_filter
()¶ Return filter function to be used for agg filter.
-
get_alpha
()¶ Return the alpha value used for blending - not supported on all backends.
-
get_animated
()¶ Return whether the artist is animated.
-
get_array
()¶ Return the data array.
-
get_capstyle
()¶
-
get_clim
()¶ Return the values (min, max) that are mapped to the colormap limits.
-
get_clip_box
()¶ Return the clipbox.
-
get_clip_on
()¶ Return whether the artist uses clipping.
-
get_clip_path
()¶ Return the clip path.
-
get_contains
()¶ [Deprecated] Return the custom contains function of the artist if set, or None.
See also
Notes
Deprecated since version 3.3.
-
get_cursor_data
(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.Parameters: See also
-
get_dashes
()¶ Alias for
get_linestyle
.
-
get_datalim
(transData)¶
-
get_ec
()¶ Alias for
get_edgecolor
.
-
get_edgecolor
()¶
-
get_edgecolors
()¶ Alias for
get_edgecolor
.
-
get_facecolor
()¶
-
get_facecolors
()¶ Alias for
get_facecolor
.
-
get_fc
()¶ Alias for
get_facecolor
.
-
get_fill
()¶ Return whether fill is set.
-
get_gid
()¶ Return the group id.
-
get_hatch
()¶ Return the current hatching pattern.
-
get_in_layout
()¶ Return boolean flag,
True
if artist is included in layout calculations.E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.
-
get_joinstyle
()¶
-
get_label
()¶ Return the label used for this artist in the legend.
-
get_linestyle
()¶
-
get_linestyles
()¶ Alias for
get_linestyle
.
-
get_linewidth
()¶
-
get_linewidths
()¶ Alias for
get_linewidth
.
-
get_ls
()¶ Alias for
get_linestyle
.
-
get_lw
()¶ Alias for
get_linewidth
.
-
get_offset_position
()¶ [Deprecated] Return how offsets are applied for the collection. If offset_position is 'screen', the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Notes
Deprecated since version 3.3.
-
get_offset_transform
()¶
-
get_offsets
()¶ Return the offsets for the collection.
-
get_path_effects
()¶
-
get_paths
()¶
-
get_picker
()¶ Return the picking behavior of the artist.
The possible values are described in
set_picker
.See also
-
get_pickradius
()¶
-
get_rasterized
()¶ Return whether the artist is to be rasterized.
-
get_sizes
()¶ Return the sizes ('areas') of the elements in the collection.
Returns: - array
The 'area' of each element.
-
get_sketch_params
()¶ Return the sketch parameters for the artist.
Returns: - tuple or None
A 3-tuple with the following elements:
- scale: The amplitude of the wiggle perpendicular to the source line.
- length: The length of the wiggle along the line.
- randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
-
get_tightbbox
(renderer)¶ Like
Artist.get_window_extent
, but includes any clipping.Parameters: - renderer
RendererBase
subclass renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
Returns: Bbox
The enclosing bounding box (in figure pixel coordinates).
- renderer
-
get_transformed_clip_path_and_affine
()¶ Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
-
get_transforms
()¶
-
get_url
()¶ Return the url.
-
get_urls
()¶ Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
-
get_visible
()¶ Return the visibility.
-
get_window_extent
(renderer)¶ Get the axes bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
-
get_zorder
()¶ Return the artist's zorder.
-
have_units
()¶ Return True if units are set on any axis.
-
is_transform_set
()¶ Return whether the Artist has an explicitly set transform.
This is True after
set_transform
has been called.
-
property
mouseover
¶ If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also
get_cursor_data()
,ToolCursorPosition
andNavigationToolbar2
.
-
pchanged
()¶ Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
-
pick
(mouseevent)¶ Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
-
pickable
()¶ Return whether the artist is pickable.
See also
-
properties
()¶ Return a dictionary of all the properties of the artist.
-
remove
()¶ Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with
FigureCanvasBase.draw_idle
. Callrelim
to update the axes limits if desired.Note:
relim
will not see collections even if the collection was added to the axes with autolim = True.Note: there is no support for removing the artist's legend entry.
-
remove_callback
(oid)¶ Remove a callback based on its observer id.
See also
-
set
(**kwargs)¶ A property batch setter. Pass kwargs to set properties.
-
set_aa
(aa)¶ Alias for
set_antialiased
.
-
set_agg_filter
(filter_func)¶ Set the agg filter.
Parameters: - filter_funccallable
A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.
-
set_alpha
(alpha)¶ Set the alpha value used for blending - not supported on all backends.
Parameters: - alphafloat or None
-
set_animated
(b)¶ Set the artist's animation state.
Parameters: - bbool
-
set_antialiased
(aa)¶ Set the antialiasing state for rendering.
Parameters: - aabool or list of bools
-
set_antialiaseds
(aa)¶ Alias for
set_antialiased
.
-
set_array
(A)¶ Set the image array from numpy array A.
Parameters: - Andarray
-
set_capstyle
(cs)¶ Set the capstyle for the collection (for all its elements).
Parameters: - cs{'butt', 'round', 'projecting'}
The capstyle.
-
set_clim
(vmin=None, vmax=None)¶ Set the norm limits for image scaling.
Parameters: - vmin, vmaxfloat
The limits.
The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
-
set_clip_on
(b)¶ Set whether the artist uses clipping.
When False artists will be visible outside of the axes which can lead to unexpected results.
Parameters: - bbool
-
set_clip_path
(path, transform=None)¶ Set the artist's clip path.
Parameters: - path
Patch
orPath
orTransformedPath
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
Transform
, optional Only used if path is a
Path
, in which case the givenPath
is converted to aTransformedPath
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 toNone
.For technical reasons (support of
set
), a tuple (path, transform) is also accepted as a single positional parameter.- path
-
set_color
(c)¶ Set both the edgecolor and the facecolor.
Parameters: - ccolor or list of rgba tuples
See also
Collection.set_facecolor
,Collection.set_edgecolor
- For setting the edge or face color individually.
-
set_contains
(picker)¶ [Deprecated] Define a custom contains test for the artist.
The provided callable replaces the default
contains
method of the artist.Parameters: - pickercallable
A custom picker function to evaluate if an event is within the artist. The function must have the signature:
def contains(artist: Artist, event: MouseEvent) -> bool, dict
that returns:
- a bool indicating if the event is within the artist
- a dict of additional information. The dict should at least
return the same information as the default
contains()
implementation of the respective artist, but may provide additional information.
Notes
Deprecated since version 3.3.
-
set_dashes
(ls)¶ Alias for
set_linestyle
.
-
set_ec
(c)¶ Alias for
set_edgecolor
.
-
set_edgecolor
(c)¶ Set the edgecolor(s) of the collection.
Parameters: - ccolor or list of colors or 'face'
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
-
set_edgecolors
(c)¶ Alias for
set_edgecolor
.
-
set_facecolor
(c)¶ Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Parameters: - ccolor or list of colors
-
set_facecolors
(c)¶ Alias for
set_facecolor
.
-
set_fc
(c)¶ Alias for
set_facecolor
.
-
set_gid
(gid)¶ Set the (group) id for the artist.
Parameters: - gidstr
-
set_hatch
(hatch)¶ Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Parameters: - hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
-
set_in_layout
(in_layout)¶ Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.Parameters: - in_layoutbool
-
set_joinstyle
(js)¶ Set the joinstyle for the collection (for all its elements).
Parameters: - js{'miter', 'round', 'bevel'}
The joinstyle.
-
set_label
(s)¶ Set a label that will be displayed in the legend.
Parameters: - sobject
s will be converted to a string by calling
str
.
-
set_linestyle
(ls)¶ Set the linestyle(s) for the collection.
linestyle description '-'
or'solid'
solid line '--'
or'dashed'
dashed line '-.'
or'dashdot'
dash-dotted line ':'
or'dotted'
dotted line Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.Parameters: - lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for a complete description.
-
set_linestyles
(ls)¶ Alias for
set_linestyle
.
-
set_linewidth
(lw)¶ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Parameters: - lwfloat or list of floats
-
set_linewidths
(lw)¶ Alias for
set_linewidth
.
-
set_ls
(ls)¶ Alias for
set_linestyle
.
-
set_lw
(lw)¶ Alias for
set_linewidth
.
-
set_norm
(norm)¶ Set the normalization instance.
Parameters: - norm
Normalize
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.
- norm
-
set_offset_position
(offset_position)¶ [Deprecated] Set how offsets are applied. If offset_position is 'screen' (default) the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Parameters: - offset_position{'screen', 'data'}
Notes
Deprecated since version 3.3.
-
set_offsets
(offsets)¶ Set the offsets for the collection.
Parameters: - offsetsarray-like (N, 2) or (2,)
-
set_path_effects
(path_effects)¶ Set the path effects.
Parameters: - path_effects
AbstractPathEffect
- path_effects
-
set_paths
(verts, closed=True)¶ Set the vertices of the polygons.
Parameters: - vertslist of array-like
The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).
- closedbool, default: True
Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.
-
set_picker
(picker)¶ Define the picking behavior of the artist.
Parameters: - pickerNone or bool or callable
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A 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.
deprecated: For
Line2D
only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. UseLine2D.set_pickradius
instead.
-
set_pickradius
(pr)¶ Set the pick radius used for containment tests.
Parameters: - dfloat
Pick radius, in points.
-
set_rasterized
(rasterized)¶ Force rasterized (bitmap) drawing in vector backend output.
Defaults to None, which implies the backend's default behavior.
Parameters: - rasterizedbool or None
-
set_sizes
(sizes, dpi=72.0)¶ Set the sizes of each member of the collection.
Parameters: - sizesndarray or None
The size to set for each element of the collection. The value is the 'area' of the element.
- dpifloat, default: 72
The dpi of the canvas.
-
set_sketch_params
(scale=None, length=None, randomness=None)¶ Sets the sketch parameters.
Parameters: - scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is
None
, or not provided, no sketch filter will be provided.- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
-
set_snap
(snap)¶ Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters: - snapbool or None
Possible values:
- True: Snap vertices to the nearest pixel center.
- False: Do not modify vertex positions.
- None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
-
set_url
(url)¶ Set the url for the artist.
Parameters: - urlstr
-
set_urls
(urls)¶ Parameters: - urlslist of str or None
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
-
set_verts
(verts, closed=True)[source]¶ Set the vertices of the polygons.
Parameters: - vertslist of array-like
The sequence of polygons [verts0, verts1, ...] where each element verts_i defines the vertices of polygon i as a 2D array-like of shape (M, 2).
- closedbool, default: True
Whether the polygon should be closed by adding a CLOSEPOLY connection at the end.
-
set_visible
(b)¶ Set the artist's visibility.
Parameters: - bbool
-
set_zorder
(level)¶ Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters: - levelfloat
-
property
stale
¶ Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
-
property
sticky_edges
¶ x
andy
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.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
-
to_rgba
(x, alpha=None, bytes=False, norm=True)¶ Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
-
update
(props)¶ Update this artist's properties from the dict props.
Parameters: - propsdict
-
property
update_dict
¶
-
update_from
(other)¶ Copy properties from other to self.
-
update_scalarmappable
()¶ Update colors from the scalar mappable array, if it is not None.
-
zorder
= 0¶
-
class
matplotlib.collections.
QuadMesh
(meshWidth, meshHeight, coordinates, antialiased=True, shading='flat', **kwargs)[source]¶ Bases:
matplotlib.collections.Collection
Class for the efficient drawing of a quadrilateral mesh.
A quadrilateral mesh consists of a grid of vertices. The dimensions of this array are (meshWidth + 1, meshHeight + 1). Each vertex in the mesh has a different set of "mesh coordinates" representing its position in the topology of the mesh. For any values (m, n) such that 0 <= m <= meshWidth and 0 <= n <= meshHeight, the vertices at mesh coordinates (m, n), (m, n + 1), (m + 1, n + 1), and (m + 1, n) form one of the quadrilaterals in the mesh. There are thus (meshWidth * meshHeight) quadrilaterals in the mesh. The mesh need not be regular and the polygons need not be convex.
A quadrilateral mesh is represented by a (2 x ((meshWidth + 1) * (meshHeight + 1))) numpy array coordinates, where each row is the x and y coordinates of one of the vertices. To define the function that maps from a data point to its corresponding color, use the
set_cmap()
method. Each of these arrays is indexed in row-major order by the mesh coordinates of the vertex (or the mesh coordinates of the lower left vertex, in the case of the colors).For example, the first entry in coordinates is the coordinates of the vertex at mesh coordinates (0, 0), then the one at (0, 1), then at (0, 2) .. (0, meshWidth), (1, 0), (1, 1), and so on.
shading may be 'flat', or 'gouraud'
Parameters: - edgecolorscolor or list of colors, default:
rcParams["patch.edgecolor"]
(default:'black'
) Edge color for each patch making up the collection. The special value 'face' can be passed to make the edgecolor match the facecolor.
- facecolorscolor or list of colors, default:
rcParams["patch.facecolor"]
(default:'C0'
) Face color for each patch making up the collection.
- linewidthsfloat or list of floats, default:
rcParams["patch.linewidth"]
(default:1.0
) Line width for each patch making up the collection.
- linestylesstr or tuple or list thereof, default: 'solid'
Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:
(offset, onoffseq),
where onoffseq is an even length tuple of on and off ink lengths in points. For examples, see Linestyles.
- capstylestr, default:
rcParams["patch.capstyle"]
Style to use for capping lines for all paths in the collection. See Join styles and cap styles for a demonstration of each of the allowed values.
- joinstylestr, default:
rcParams["patch.joinstyle"]
Style to use for joining lines for all paths in the collection. See Join styles and cap styles for a demonstration of each of the allowed values.
- antialiasedsbool or list of bool, default:
rcParams["patch.antialiased"]
(default:True
) Whether each pach in the collection should be drawn with antialiasing.
- offsets(float, float) or list thereof, default: (0, 0)
A vector by which to translate each patch after rendering (default is no translation). The translation is performed in screen (pixel) coordinates (i.e. after the Artist's transform is applied).
- transOffset
Transform
, default:IdentityTransform
A single transform which will be applied to each offsets vector before it is used.
- offset_position{'screen' (default), 'data' (deprecated)}
If set to 'data' (deprecated), offsets will be treated as if it is in data coordinates instead of in screen coordinates.
- norm
Normalize
, optional Forwarded to
ScalarMappable
. The default ofNone
means that the first draw call will setvmin
andvmax
using the minimum and maximum values of the data.- cmap
Colormap
, optional Forwarded to
ScalarMappable
. The default ofNone
will result inrcParams["image.cmap"]
(default:'viridis'
) being used.- hatchstr, optional
Hatching pattern to use in filled paths, if any. Valid strings are ['/', '', '|', '-', '+', 'x', 'o', 'O', '.', '*']. See Hatch Demo for the meaning of each hatch type.
- pickradiusfloat, default: 5.0
If
pickradius <= 0
, thenCollection.contains
will returnTrue
whenever the test point is inside of one of the 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 width2*pickradius
following any of the Paths in the Collection.- urlslist of str, default: None
A URL for each patch to link to once drawn. Currently only works for the SVG backend. See Hyperlinks for examples.
- zorderfloat, default: 1
The drawing order, shared by all Patches in the Collection. See Zorder Demo for all defaults and examples.
-
add_callback
(func)¶ Add a callback function that will be called whenever one of the
Artist
's properties changes.Parameters: - funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling
Artist
. Return values may exist but are ignored.
Returns: - int
The observer id associated with the callback. This id can be used for removing the callback with
remove_callback
later.
See also
-
add_checker
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
autoscale
()¶ Autoscale the scalar limits on the norm instance using the current array
-
autoscale_None
()¶ Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
-
changed
()¶ Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
-
check_update
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
contains
(mouseevent)¶ Test whether the mouse event occurred in the collection.
Returns
bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
-
static
convert_mesh_to_paths
(meshWidth, meshHeight, coordinates)[source]¶ Convert a given mesh into a sequence of
Path
objects.This function is primarily of use to implementers of backends that do not directly support quadmeshes.
-
convert_mesh_to_triangles
(meshWidth, meshHeight, coordinates)[source]¶ Convert a given mesh into a sequence of triangles, each point with its own color. This is useful for experiments using
draw_gouraud_triangle
.
-
convert_xunits
(x)¶ Convert x using the unit type of the xaxis.
If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.
-
convert_yunits
(y)¶ Convert y using the unit type of the yaxis.
If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.
-
draw
(renderer)[source]¶ Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visible
returns False).Parameters: - renderer
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
- renderer
-
findobj
(match=None, include_self=True)¶ Find artist objects.
Recursively find all
Artist
instances contained in the artist.Parameters: - match
A filter criterion for the matches. This can be
- None: Return all objects contained in artist.
- A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True. - A class instance: e.g.,
Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
- include_selfbool
Include self in the list to be checked for a match.
Returns: - list of
Artist
-
format_cursor_data
(data)¶ 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.
See also
-
get_agg_filter
()¶ Return filter function to be used for agg filter.
-
get_alpha
()¶ Return the alpha value used for blending - not supported on all backends.
-
get_animated
()¶ Return whether the artist is animated.
-
get_array
()¶ Return the data array.
-
get_capstyle
()¶
-
get_clim
()¶ Return the values (min, max) that are mapped to the colormap limits.
-
get_clip_box
()¶ Return the clipbox.
-
get_clip_on
()¶ Return whether the artist uses clipping.
-
get_clip_path
()¶ Return the clip path.
-
get_contains
()¶ [Deprecated] Return the custom contains function of the artist if set, or None.
See also
Notes
Deprecated since version 3.3.
-
get_cursor_data
(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.Parameters: See also
-
get_dashes
()¶ Alias for
get_linestyle
.
-
get_ec
()¶ Alias for
get_edgecolor
.
-
get_edgecolor
()¶
-
get_edgecolors
()¶ Alias for
get_edgecolor
.
-
get_facecolor
()¶
-
get_facecolors
()¶ Alias for
get_facecolor
.
-
get_fc
()¶ Alias for
get_facecolor
.
-
get_fill
()¶ Return whether fill is set.
-
get_gid
()¶ Return the group id.
-
get_hatch
()¶ Return the current hatching pattern.
-
get_in_layout
()¶ Return boolean flag,
True
if artist is included in layout calculations.E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.
-
get_joinstyle
()¶
-
get_label
()¶ Return the label used for this artist in the legend.
-
get_linestyle
()¶
-
get_linestyles
()¶ Alias for
get_linestyle
.
-
get_linewidth
()¶
-
get_linewidths
()¶ Alias for
get_linewidth
.
-
get_ls
()¶ Alias for
get_linestyle
.
-
get_lw
()¶ Alias for
get_linewidth
.
-
get_offset_position
()¶ [Deprecated] Return how offsets are applied for the collection. If offset_position is 'screen', the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Notes
Deprecated since version 3.3.
-
get_offset_transform
()¶
-
get_offsets
()¶ Return the offsets for the collection.
-
get_path_effects
()¶
-
get_picker
()¶ Return the picking behavior of the artist.
The possible values are described in
set_picker
.See also
-
get_pickradius
()¶
-
get_rasterized
()¶ Return whether the artist is to be rasterized.
-
get_sketch_params
()¶ Return the sketch parameters for the artist.
Returns: - tuple or None
A 3-tuple with the following elements:
- scale: The amplitude of the wiggle perpendicular to the source line.
- length: The length of the wiggle along the line.
- randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
-
get_tightbbox
(renderer)¶ Like
Artist.get_window_extent
, but includes any clipping.Parameters: - renderer
RendererBase
subclass renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
Returns: Bbox
The enclosing bounding box (in figure pixel coordinates).
- renderer
-
get_transformed_clip_path_and_affine
()¶ Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
-
get_transforms
()¶
-
get_url
()¶ Return the url.
-
get_urls
()¶ Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
-
get_visible
()¶ Return the visibility.
-
get_window_extent
(renderer)¶ Get the axes bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
-
get_zorder
()¶ Return the artist's zorder.
-
have_units
()¶ Return True if units are set on any axis.
-
is_transform_set
()¶ Return whether the Artist has an explicitly set transform.
This is True after
set_transform
has been called.
-
property
mouseover
¶ If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also
get_cursor_data()
,ToolCursorPosition
andNavigationToolbar2
.
-
pchanged
()¶ Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
-
pick
(mouseevent)¶ Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
-
pickable
()¶ Return whether the artist is pickable.
See also
-
properties
()¶ Return a dictionary of all the properties of the artist.
-
remove
()¶ Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with
FigureCanvasBase.draw_idle
. Callrelim
to update the axes limits if desired.Note:
relim
will not see collections even if the collection was added to the axes with autolim = True.Note: there is no support for removing the artist's legend entry.
-
remove_callback
(oid)¶ Remove a callback based on its observer id.
See also
-
set
(**kwargs)¶ A property batch setter. Pass kwargs to set properties.
-
set_aa
(aa)¶ Alias for
set_antialiased
.
-
set_agg_filter
(filter_func)¶ Set the agg filter.
Parameters: - filter_funccallable
A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.
-
set_alpha
(alpha)¶ Set the alpha value used for blending - not supported on all backends.
Parameters: - alphafloat or None
-
set_animated
(b)¶ Set the artist's animation state.
Parameters: - bbool
-
set_antialiased
(aa)¶ Set the antialiasing state for rendering.
Parameters: - aabool or list of bools
-
set_antialiaseds
(aa)¶ Alias for
set_antialiased
.
-
set_array
(A)¶ Set the image array from numpy array A.
Parameters: - Andarray
-
set_capstyle
(cs)¶ Set the capstyle for the collection (for all its elements).
Parameters: - cs{'butt', 'round', 'projecting'}
The capstyle.
-
set_clim
(vmin=None, vmax=None)¶ Set the norm limits for image scaling.
Parameters: - vmin, vmaxfloat
The limits.
The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
-
set_clip_on
(b)¶ Set whether the artist uses clipping.
When False artists will be visible outside of the axes which can lead to unexpected results.
Parameters: - bbool
-
set_clip_path
(path, transform=None)¶ Set the artist's clip path.
Parameters: - path
Patch
orPath
orTransformedPath
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
Transform
, optional Only used if path is a
Path
, in which case the givenPath
is converted to aTransformedPath
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 toNone
.For technical reasons (support of
set
), a tuple (path, transform) is also accepted as a single positional parameter.- path
-
set_color
(c)¶ Set both the edgecolor and the facecolor.
Parameters: - ccolor or list of rgba tuples
See also
Collection.set_facecolor
,Collection.set_edgecolor
- For setting the edge or face color individually.
-
set_contains
(picker)¶ [Deprecated] Define a custom contains test for the artist.
The provided callable replaces the default
contains
method of the artist.Parameters: - pickercallable
A custom picker function to evaluate if an event is within the artist. The function must have the signature:
def contains(artist: Artist, event: MouseEvent) -> bool, dict
that returns:
- a bool indicating if the event is within the artist
- a dict of additional information. The dict should at least
return the same information as the default
contains()
implementation of the respective artist, but may provide additional information.
Notes
Deprecated since version 3.3.
-
set_dashes
(ls)¶ Alias for
set_linestyle
.
-
set_ec
(c)¶ Alias for
set_edgecolor
.
-
set_edgecolor
(c)¶ Set the edgecolor(s) of the collection.
Parameters: - ccolor or list of colors or 'face'
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
-
set_edgecolors
(c)¶ Alias for
set_edgecolor
.
-
set_facecolor
(c)¶ Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Parameters: - ccolor or list of colors
-
set_facecolors
(c)¶ Alias for
set_facecolor
.
-
set_fc
(c)¶ Alias for
set_facecolor
.
-
set_gid
(gid)¶ Set the (group) id for the artist.
Parameters: - gidstr
-
set_hatch
(hatch)¶ Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Parameters: - hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
-
set_in_layout
(in_layout)¶ Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.Parameters: - in_layoutbool
-
set_joinstyle
(js)¶ Set the joinstyle for the collection (for all its elements).
Parameters: - js{'miter', 'round', 'bevel'}
The joinstyle.
-
set_label
(s)¶ Set a label that will be displayed in the legend.
Parameters: - sobject
s will be converted to a string by calling
str
.
-
set_linestyle
(ls)¶ Set the linestyle(s) for the collection.
linestyle description '-'
or'solid'
solid line '--'
or'dashed'
dashed line '-.'
or'dashdot'
dash-dotted line ':'
or'dotted'
dotted line Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.Parameters: - lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for a complete description.
-
set_linestyles
(ls)¶ Alias for
set_linestyle
.
-
set_linewidth
(lw)¶ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Parameters: - lwfloat or list of floats
-
set_linewidths
(lw)¶ Alias for
set_linewidth
.
-
set_ls
(ls)¶ Alias for
set_linestyle
.
-
set_lw
(lw)¶ Alias for
set_linewidth
.
-
set_norm
(norm)¶ Set the normalization instance.
Parameters: - norm
Normalize
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.
- norm
-
set_offset_position
(offset_position)¶ [Deprecated] Set how offsets are applied. If offset_position is 'screen' (default) the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Parameters: - offset_position{'screen', 'data'}
Notes
Deprecated since version 3.3.
-
set_offsets
(offsets)¶ Set the offsets for the collection.
Parameters: - offsetsarray-like (N, 2) or (2,)
-
set_path_effects
(path_effects)¶ Set the path effects.
Parameters: - path_effects
AbstractPathEffect
- path_effects
-
set_picker
(picker)¶ Define the picking behavior of the artist.
Parameters: - pickerNone or bool or callable
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A 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.
deprecated: For
Line2D
only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. UseLine2D.set_pickradius
instead.
-
set_pickradius
(pr)¶ Set the pick radius used for containment tests.
Parameters: - dfloat
Pick radius, in points.
-
set_rasterized
(rasterized)¶ Force rasterized (bitmap) drawing in vector backend output.
Defaults to None, which implies the backend's default behavior.
Parameters: - rasterizedbool or None
-
set_sketch_params
(scale=None, length=None, randomness=None)¶ Sets the sketch parameters.
Parameters: - scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is
None
, or not provided, no sketch filter will be provided.- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
-
set_snap
(snap)¶ Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters: - snapbool or None
Possible values:
- True: Snap vertices to the nearest pixel center.
- False: Do not modify vertex positions.
- None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
-
set_url
(url)¶ Set the url for the artist.
Parameters: - urlstr
-
set_urls
(urls)¶ Parameters: - urlslist of str or None
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
-
set_visible
(b)¶ Set the artist's visibility.
Parameters: - bbool
-
set_zorder
(level)¶ Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters: - levelfloat
-
property
stale
¶ Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
-
property
sticky_edges
¶ x
andy
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.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
-
to_rgba
(x, alpha=None, bytes=False, norm=True)¶ Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
-
update
(props)¶ Update this artist's properties from the dict props.
Parameters: - propsdict
-
property
update_dict
¶
-
update_from
(other)¶ Copy properties from other to self.
-
update_scalarmappable
()¶ Update colors from the scalar mappable array, if it is not None.
-
zorder
= 0¶
- edgecolorscolor or list of colors, default:
-
class
matplotlib.collections.
RegularPolyCollection
(numsides, rotation=0, sizes=(1), **kwargs)[source]¶ Bases:
matplotlib.collections._CollectionWithSizes
A collection of n-sided regular polygons.
Parameters: - numsidesint
The number of sides of the polygon.
- rotationfloat
The rotation of the polygon in radians.
- sizestuple of float
The area of the circle circumscribing the polygon in points^2.
- **kwargs
Forwarded to
Collection
.
Examples
See Lasso Demo for a complete example:
offsets = np.random.rand(20, 2) facecolors = [cm.jet(x) for x in np.random.rand(20)] collection = RegularPolyCollection( numsides=5, # a pentagon rotation=0, sizes=(50,), facecolors=facecolors, edgecolors=("black",), linewidths=(1,), offsets=offsets, transOffset=ax.transData, )
-
add_callback
(func)¶ Add a callback function that will be called whenever one of the
Artist
's properties changes.Parameters: - funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling
Artist
. Return values may exist but are ignored.
Returns: - int
The observer id associated with the callback. This id can be used for removing the callback with
remove_callback
later.
See also
-
add_checker
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
autoscale
()¶ Autoscale the scalar limits on the norm instance using the current array
-
autoscale_None
()¶ Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
-
changed
()¶ Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
-
check_update
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
contains
(mouseevent)¶ Test whether the mouse event occurred in the collection.
Returns
bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
-
convert_xunits
(x)¶ Convert x using the unit type of the xaxis.
If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.
-
convert_yunits
(y)¶ Convert y using the unit type of the yaxis.
If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.
-
draw
(renderer)[source]¶ Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visible
returns False).Parameters: - renderer
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
- renderer
-
findobj
(match=None, include_self=True)¶ Find artist objects.
Recursively find all
Artist
instances contained in the artist.Parameters: - match
A filter criterion for the matches. This can be
- None: Return all objects contained in artist.
- A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True. - A class instance: e.g.,
Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
- include_selfbool
Include self in the list to be checked for a match.
Returns: - list of
Artist
-
format_cursor_data
(data)¶ 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.
See also
-
get_agg_filter
()¶ Return filter function to be used for agg filter.
-
get_alpha
()¶ Return the alpha value used for blending - not supported on all backends.
-
get_animated
()¶ Return whether the artist is animated.
-
get_array
()¶ Return the data array.
-
get_capstyle
()¶
-
get_clim
()¶ Return the values (min, max) that are mapped to the colormap limits.
-
get_clip_box
()¶ Return the clipbox.
-
get_clip_on
()¶ Return whether the artist uses clipping.
-
get_clip_path
()¶ Return the clip path.
-
get_contains
()¶ [Deprecated] Return the custom contains function of the artist if set, or None.
See also
Notes
Deprecated since version 3.3.
-
get_cursor_data
(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.Parameters: See also
-
get_dashes
()¶ Alias for
get_linestyle
.
-
get_datalim
(transData)¶
-
get_ec
()¶ Alias for
get_edgecolor
.
-
get_edgecolor
()¶
-
get_edgecolors
()¶ Alias for
get_edgecolor
.
-
get_facecolor
()¶
-
get_facecolors
()¶ Alias for
get_facecolor
.
-
get_fc
()¶ Alias for
get_facecolor
.
-
get_fill
()¶ Return whether fill is set.
-
get_gid
()¶ Return the group id.
-
get_hatch
()¶ Return the current hatching pattern.
-
get_in_layout
()¶ Return boolean flag,
True
if artist is included in layout calculations.E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.
-
get_joinstyle
()¶
-
get_label
()¶ Return the label used for this artist in the legend.
-
get_linestyle
()¶
-
get_linestyles
()¶ Alias for
get_linestyle
.
-
get_linewidth
()¶
-
get_linewidths
()¶ Alias for
get_linewidth
.
-
get_ls
()¶ Alias for
get_linestyle
.
-
get_lw
()¶ Alias for
get_linewidth
.
-
get_offset_position
()¶ [Deprecated] Return how offsets are applied for the collection. If offset_position is 'screen', the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Notes
Deprecated since version 3.3.
-
get_offset_transform
()¶
-
get_offsets
()¶ Return the offsets for the collection.
-
get_path_effects
()¶
-
get_paths
()¶
-
get_picker
()¶ Return the picking behavior of the artist.
The possible values are described in
set_picker
.See also
-
get_pickradius
()¶
-
get_rasterized
()¶ Return whether the artist is to be rasterized.
-
get_sizes
()¶ Return the sizes ('areas') of the elements in the collection.
Returns: - array
The 'area' of each element.
-
get_sketch_params
()¶ Return the sketch parameters for the artist.
Returns: - tuple or None
A 3-tuple with the following elements:
- scale: The amplitude of the wiggle perpendicular to the source line.
- length: The length of the wiggle along the line.
- randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
-
get_tightbbox
(renderer)¶ Like
Artist.get_window_extent
, but includes any clipping.Parameters: - renderer
RendererBase
subclass renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
Returns: Bbox
The enclosing bounding box (in figure pixel coordinates).
- renderer
-
get_transformed_clip_path_and_affine
()¶ Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
-
get_transforms
()¶
-
get_url
()¶ Return the url.
-
get_urls
()¶ Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
-
get_visible
()¶ Return the visibility.
-
get_window_extent
(renderer)¶ Get the axes bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
-
get_zorder
()¶ Return the artist's zorder.
-
have_units
()¶ Return True if units are set on any axis.
-
is_transform_set
()¶ Return whether the Artist has an explicitly set transform.
This is True after
set_transform
has been called.
-
property
mouseover
¶ If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also
get_cursor_data()
,ToolCursorPosition
andNavigationToolbar2
.
-
pchanged
()¶ Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
-
pick
(mouseevent)¶ Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
-
pickable
()¶ Return whether the artist is pickable.
See also
-
properties
()¶ Return a dictionary of all the properties of the artist.
-
remove
()¶ Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with
FigureCanvasBase.draw_idle
. Callrelim
to update the axes limits if desired.Note:
relim
will not see collections even if the collection was added to the axes with autolim = True.Note: there is no support for removing the artist's legend entry.
-
remove_callback
(oid)¶ Remove a callback based on its observer id.
See also
-
set
(**kwargs)¶ A property batch setter. Pass kwargs to set properties.
-
set_aa
(aa)¶ Alias for
set_antialiased
.
-
set_agg_filter
(filter_func)¶ Set the agg filter.
Parameters: - filter_funccallable
A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.
-
set_alpha
(alpha)¶ Set the alpha value used for blending - not supported on all backends.
Parameters: - alphafloat or None
-
set_animated
(b)¶ Set the artist's animation state.
Parameters: - bbool
-
set_antialiased
(aa)¶ Set the antialiasing state for rendering.
Parameters: - aabool or list of bools
-
set_antialiaseds
(aa)¶ Alias for
set_antialiased
.
-
set_array
(A)¶ Set the image array from numpy array A.
Parameters: - Andarray
-
set_capstyle
(cs)¶ Set the capstyle for the collection (for all its elements).
Parameters: - cs{'butt', 'round', 'projecting'}
The capstyle.
-
set_clim
(vmin=None, vmax=None)¶ Set the norm limits for image scaling.
Parameters: - vmin, vmaxfloat
The limits.
The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
-
set_clip_on
(b)¶ Set whether the artist uses clipping.
When False artists will be visible outside of the axes which can lead to unexpected results.
Parameters: - bbool
-
set_clip_path
(path, transform=None)¶ Set the artist's clip path.
Parameters: - path
Patch
orPath
orTransformedPath
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
Transform
, optional Only used if path is a
Path
, in which case the givenPath
is converted to aTransformedPath
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 toNone
.For technical reasons (support of
set
), a tuple (path, transform) is also accepted as a single positional parameter.- path
-
set_color
(c)¶ Set both the edgecolor and the facecolor.
Parameters: - ccolor or list of rgba tuples
See also
Collection.set_facecolor
,Collection.set_edgecolor
- For setting the edge or face color individually.
-
set_contains
(picker)¶ [Deprecated] Define a custom contains test for the artist.
The provided callable replaces the default
contains
method of the artist.Parameters: - pickercallable
A custom picker function to evaluate if an event is within the artist. The function must have the signature:
def contains(artist: Artist, event: MouseEvent) -> bool, dict
that returns:
- a bool indicating if the event is within the artist
- a dict of additional information. The dict should at least
return the same information as the default
contains()
implementation of the respective artist, but may provide additional information.
Notes
Deprecated since version 3.3.
-
set_dashes
(ls)¶ Alias for
set_linestyle
.
-
set_ec
(c)¶ Alias for
set_edgecolor
.
-
set_edgecolor
(c)¶ Set the edgecolor(s) of the collection.
Parameters: - ccolor or list of colors or 'face'
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
-
set_edgecolors
(c)¶ Alias for
set_edgecolor
.
-
set_facecolor
(c)¶ Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Parameters: - ccolor or list of colors
-
set_facecolors
(c)¶ Alias for
set_facecolor
.
-
set_fc
(c)¶ Alias for
set_facecolor
.
-
set_gid
(gid)¶ Set the (group) id for the artist.
Parameters: - gidstr
-
set_hatch
(hatch)¶ Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Parameters: - hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
-
set_in_layout
(in_layout)¶ Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.Parameters: - in_layoutbool
-
set_joinstyle
(js)¶ Set the joinstyle for the collection (for all its elements).
Parameters: - js{'miter', 'round', 'bevel'}
The joinstyle.
-
set_label
(s)¶ Set a label that will be displayed in the legend.
Parameters: - sobject
s will be converted to a string by calling
str
.
-
set_linestyle
(ls)¶ Set the linestyle(s) for the collection.
linestyle description '-'
or'solid'
solid line '--'
or'dashed'
dashed line '-.'
or'dashdot'
dash-dotted line ':'
or'dotted'
dotted line Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.Parameters: - lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for a complete description.
-
set_linestyles
(ls)¶ Alias for
set_linestyle
.
-
set_linewidth
(lw)¶ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Parameters: - lwfloat or list of floats
-
set_linewidths
(lw)¶ Alias for
set_linewidth
.
-
set_ls
(ls)¶ Alias for
set_linestyle
.
-
set_lw
(lw)¶ Alias for
set_linewidth
.
-
set_norm
(norm)¶ Set the normalization instance.
Parameters: - norm
Normalize
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.
- norm
-
set_offset_position
(offset_position)¶ [Deprecated] Set how offsets are applied. If offset_position is 'screen' (default) the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Parameters: - offset_position{'screen', 'data'}
Notes
Deprecated since version 3.3.
-
set_offsets
(offsets)¶ Set the offsets for the collection.
Parameters: - offsetsarray-like (N, 2) or (2,)
-
set_path_effects
(path_effects)¶ Set the path effects.
Parameters: - path_effects
AbstractPathEffect
- path_effects
-
set_paths
()¶
-
set_picker
(picker)¶ Define the picking behavior of the artist.
Parameters: - pickerNone or bool or callable
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A 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.
deprecated: For
Line2D
only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. UseLine2D.set_pickradius
instead.
-
set_pickradius
(pr)¶ Set the pick radius used for containment tests.
Parameters: - dfloat
Pick radius, in points.
-
set_rasterized
(rasterized)¶ Force rasterized (bitmap) drawing in vector backend output.
Defaults to None, which implies the backend's default behavior.
Parameters: - rasterizedbool or None
-
set_sizes
(sizes, dpi=72.0)¶ Set the sizes of each member of the collection.
Parameters: - sizesndarray or None
The size to set for each element of the collection. The value is the 'area' of the element.
- dpifloat, default: 72
The dpi of the canvas.
-
set_sketch_params
(scale=None, length=None, randomness=None)¶ Sets the sketch parameters.
Parameters: - scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is
None
, or not provided, no sketch filter will be provided.- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
-
set_snap
(snap)¶ Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters: - snapbool or None
Possible values:
- True: Snap vertices to the nearest pixel center.
- False: Do not modify vertex positions.
- None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
-
set_url
(url)¶ Set the url for the artist.
Parameters: - urlstr
-
set_urls
(urls)¶ Parameters: - urlslist of str or None
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
-
set_visible
(b)¶ Set the artist's visibility.
Parameters: - bbool
-
set_zorder
(level)¶ Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters: - levelfloat
-
property
stale
¶ Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
-
property
sticky_edges
¶ x
andy
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.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
-
to_rgba
(x, alpha=None, bytes=False, norm=True)¶ Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
-
update
(props)¶ Update this artist's properties from the dict props.
Parameters: - propsdict
-
property
update_dict
¶
-
update_from
(other)¶ Copy properties from other to self.
-
update_scalarmappable
()¶ Update colors from the scalar mappable array, if it is not None.
-
zorder
= 0¶
-
class
matplotlib.collections.
StarPolygonCollection
(numsides, rotation=0, sizes=(1), **kwargs)[source]¶ Bases:
matplotlib.collections.RegularPolyCollection
Draw a collection of regular stars with numsides points.
Parameters: - numsidesint
The number of sides of the polygon.
- rotationfloat
The rotation of the polygon in radians.
- sizestuple of float
The area of the circle circumscribing the polygon in points^2.
- **kwargs
Forwarded to
Collection
.
Examples
See Lasso Demo for a complete example:
offsets = np.random.rand(20, 2) facecolors = [cm.jet(x) for x in np.random.rand(20)] collection = RegularPolyCollection( numsides=5, # a pentagon rotation=0, sizes=(50,), facecolors=facecolors, edgecolors=("black",), linewidths=(1,), offsets=offsets, transOffset=ax.transData, )
-
add_callback
(func)¶ Add a callback function that will be called whenever one of the
Artist
's properties changes.Parameters: - funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling
Artist
. Return values may exist but are ignored.
Returns: - int
The observer id associated with the callback. This id can be used for removing the callback with
remove_callback
later.
See also
-
add_checker
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
autoscale
()¶ Autoscale the scalar limits on the norm instance using the current array
-
autoscale_None
()¶ Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
-
changed
()¶ Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
-
check_update
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
contains
(mouseevent)¶ Test whether the mouse event occurred in the collection.
Returns
bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
-
convert_xunits
(x)¶ Convert x using the unit type of the xaxis.
If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.
-
convert_yunits
(y)¶ Convert y using the unit type of the yaxis.
If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.
-
draw
(renderer)¶ Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visible
returns False).Parameters: - renderer
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
- renderer
-
findobj
(match=None, include_self=True)¶ Find artist objects.
Recursively find all
Artist
instances contained in the artist.Parameters: - match
A filter criterion for the matches. This can be
- None: Return all objects contained in artist.
- A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True. - A class instance: e.g.,
Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
- include_selfbool
Include self in the list to be checked for a match.
Returns: - list of
Artist
-
format_cursor_data
(data)¶ 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.
See also
-
get_agg_filter
()¶ Return filter function to be used for agg filter.
-
get_alpha
()¶ Return the alpha value used for blending - not supported on all backends.
-
get_animated
()¶ Return whether the artist is animated.
-
get_array
()¶ Return the data array.
-
get_capstyle
()¶
-
get_clim
()¶ Return the values (min, max) that are mapped to the colormap limits.
-
get_clip_box
()¶ Return the clipbox.
-
get_clip_on
()¶ Return whether the artist uses clipping.
-
get_clip_path
()¶ Return the clip path.
-
get_contains
()¶ [Deprecated] Return the custom contains function of the artist if set, or None.
See also
Notes
Deprecated since version 3.3.
-
get_cursor_data
(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.Parameters: See also
-
get_dashes
()¶ Alias for
get_linestyle
.
-
get_datalim
(transData)¶
-
get_ec
()¶ Alias for
get_edgecolor
.
-
get_edgecolor
()¶
-
get_edgecolors
()¶ Alias for
get_edgecolor
.
-
get_facecolor
()¶
-
get_facecolors
()¶ Alias for
get_facecolor
.
-
get_fc
()¶ Alias for
get_facecolor
.
-
get_fill
()¶ Return whether fill is set.
-
get_gid
()¶ Return the group id.
-
get_hatch
()¶ Return the current hatching pattern.
-
get_in_layout
()¶ Return boolean flag,
True
if artist is included in layout calculations.E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.
-
get_joinstyle
()¶
-
get_label
()¶ Return the label used for this artist in the legend.
-
get_linestyle
()¶
-
get_linestyles
()¶ Alias for
get_linestyle
.
-
get_linewidth
()¶
-
get_linewidths
()¶ Alias for
get_linewidth
.
-
get_ls
()¶ Alias for
get_linestyle
.
-
get_lw
()¶ Alias for
get_linewidth
.
-
get_numsides
()¶
-
get_offset_position
()¶ [Deprecated] Return how offsets are applied for the collection. If offset_position is 'screen', the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Notes
Deprecated since version 3.3.
-
get_offset_transform
()¶
-
get_offsets
()¶ Return the offsets for the collection.
-
get_path_effects
()¶
-
get_paths
()¶
-
get_picker
()¶ Return the picking behavior of the artist.
The possible values are described in
set_picker
.See also
-
get_pickradius
()¶
-
get_rasterized
()¶ Return whether the artist is to be rasterized.
-
get_rotation
()¶
-
get_sizes
()¶ Return the sizes ('areas') of the elements in the collection.
Returns: - array
The 'area' of each element.
-
get_sketch_params
()¶ Return the sketch parameters for the artist.
Returns: - tuple or None
A 3-tuple with the following elements:
- scale: The amplitude of the wiggle perpendicular to the source line.
- length: The length of the wiggle along the line.
- randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
-
get_tightbbox
(renderer)¶ Like
Artist.get_window_extent
, but includes any clipping.Parameters: - renderer
RendererBase
subclass renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
Returns: Bbox
The enclosing bounding box (in figure pixel coordinates).
- renderer
-
get_transformed_clip_path_and_affine
()¶ Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
-
get_transforms
()¶
-
get_url
()¶ Return the url.
-
get_urls
()¶ Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
-
get_visible
()¶ Return the visibility.
-
get_window_extent
(renderer)¶ Get the axes bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
-
get_zorder
()¶ Return the artist's zorder.
-
have_units
()¶ Return True if units are set on any axis.
-
is_transform_set
()¶ Return whether the Artist has an explicitly set transform.
This is True after
set_transform
has been called.
-
property
mouseover
¶ If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also
get_cursor_data()
,ToolCursorPosition
andNavigationToolbar2
.
-
pchanged
()¶ Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
-
pick
(mouseevent)¶ Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
-
pickable
()¶ Return whether the artist is pickable.
See also
-
properties
()¶ Return a dictionary of all the properties of the artist.
-
remove
()¶ Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with
FigureCanvasBase.draw_idle
. Callrelim
to update the axes limits if desired.Note:
relim
will not see collections even if the collection was added to the axes with autolim = True.Note: there is no support for removing the artist's legend entry.
-
remove_callback
(oid)¶ Remove a callback based on its observer id.
See also
-
set
(**kwargs)¶ A property batch setter. Pass kwargs to set properties.
-
set_aa
(aa)¶ Alias for
set_antialiased
.
-
set_agg_filter
(filter_func)¶ Set the agg filter.
Parameters: - filter_funccallable
A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.
-
set_alpha
(alpha)¶ Set the alpha value used for blending - not supported on all backends.
Parameters: - alphafloat or None
-
set_animated
(b)¶ Set the artist's animation state.
Parameters: - bbool
-
set_antialiased
(aa)¶ Set the antialiasing state for rendering.
Parameters: - aabool or list of bools
-
set_antialiaseds
(aa)¶ Alias for
set_antialiased
.
-
set_array
(A)¶ Set the image array from numpy array A.
Parameters: - Andarray
-
set_capstyle
(cs)¶ Set the capstyle for the collection (for all its elements).
Parameters: - cs{'butt', 'round', 'projecting'}
The capstyle.
-
set_clim
(vmin=None, vmax=None)¶ Set the norm limits for image scaling.
Parameters: - vmin, vmaxfloat
The limits.
The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
-
set_clip_on
(b)¶ Set whether the artist uses clipping.
When False artists will be visible outside of the axes which can lead to unexpected results.
Parameters: - bbool
-
set_clip_path
(path, transform=None)¶ Set the artist's clip path.
Parameters: - path
Patch
orPath
orTransformedPath
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
Transform
, optional Only used if path is a
Path
, in which case the givenPath
is converted to aTransformedPath
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 toNone
.For technical reasons (support of
set
), a tuple (path, transform) is also accepted as a single positional parameter.- path
-
set_color
(c)¶ Set both the edgecolor and the facecolor.
Parameters: - ccolor or list of rgba tuples
See also
Collection.set_facecolor
,Collection.set_edgecolor
- For setting the edge or face color individually.
-
set_contains
(picker)¶ [Deprecated] Define a custom contains test for the artist.
The provided callable replaces the default
contains
method of the artist.Parameters: - pickercallable
A custom picker function to evaluate if an event is within the artist. The function must have the signature:
def contains(artist: Artist, event: MouseEvent) -> bool, dict
that returns:
- a bool indicating if the event is within the artist
- a dict of additional information. The dict should at least
return the same information as the default
contains()
implementation of the respective artist, but may provide additional information.
Notes
Deprecated since version 3.3.
-
set_dashes
(ls)¶ Alias for
set_linestyle
.
-
set_ec
(c)¶ Alias for
set_edgecolor
.
-
set_edgecolor
(c)¶ Set the edgecolor(s) of the collection.
Parameters: - ccolor or list of colors or 'face'
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
-
set_edgecolors
(c)¶ Alias for
set_edgecolor
.
-
set_facecolor
(c)¶ Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Parameters: - ccolor or list of colors
-
set_facecolors
(c)¶ Alias for
set_facecolor
.
-
set_fc
(c)¶ Alias for
set_facecolor
.
-
set_gid
(gid)¶ Set the (group) id for the artist.
Parameters: - gidstr
-
set_hatch
(hatch)¶ Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Parameters: - hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
-
set_in_layout
(in_layout)¶ Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.Parameters: - in_layoutbool
-
set_joinstyle
(js)¶ Set the joinstyle for the collection (for all its elements).
Parameters: - js{'miter', 'round', 'bevel'}
The joinstyle.
-
set_label
(s)¶ Set a label that will be displayed in the legend.
Parameters: - sobject
s will be converted to a string by calling
str
.
-
set_linestyle
(ls)¶ Set the linestyle(s) for the collection.
linestyle description '-'
or'solid'
solid line '--'
or'dashed'
dashed line '-.'
or'dashdot'
dash-dotted line ':'
or'dotted'
dotted line Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.Parameters: - lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for a complete description.
-
set_linestyles
(ls)¶ Alias for
set_linestyle
.
-
set_linewidth
(lw)¶ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Parameters: - lwfloat or list of floats
-
set_linewidths
(lw)¶ Alias for
set_linewidth
.
-
set_ls
(ls)¶ Alias for
set_linestyle
.
-
set_lw
(lw)¶ Alias for
set_linewidth
.
-
set_norm
(norm)¶ Set the normalization instance.
Parameters: - norm
Normalize
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.
- norm
-
set_offset_position
(offset_position)¶ [Deprecated] Set how offsets are applied. If offset_position is 'screen' (default) the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Parameters: - offset_position{'screen', 'data'}
Notes
Deprecated since version 3.3.
-
set_offsets
(offsets)¶ Set the offsets for the collection.
Parameters: - offsetsarray-like (N, 2) or (2,)
-
set_path_effects
(path_effects)¶ Set the path effects.
Parameters: - path_effects
AbstractPathEffect
- path_effects
-
set_paths
()¶
-
set_picker
(picker)¶ Define the picking behavior of the artist.
Parameters: - pickerNone or bool or callable
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A 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.
deprecated: For
Line2D
only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. UseLine2D.set_pickradius
instead.
-
set_pickradius
(pr)¶ Set the pick radius used for containment tests.
Parameters: - dfloat
Pick radius, in points.
-
set_rasterized
(rasterized)¶ Force rasterized (bitmap) drawing in vector backend output.
Defaults to None, which implies the backend's default behavior.
Parameters: - rasterizedbool or None
-
set_sizes
(sizes, dpi=72.0)¶ Set the sizes of each member of the collection.
Parameters: - sizesndarray or None
The size to set for each element of the collection. The value is the 'area' of the element.
- dpifloat, default: 72
The dpi of the canvas.
-
set_sketch_params
(scale=None, length=None, randomness=None)¶ Sets the sketch parameters.
Parameters: - scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is
None
, or not provided, no sketch filter will be provided.- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
-
set_snap
(snap)¶ Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters: - snapbool or None
Possible values:
- True: Snap vertices to the nearest pixel center.
- False: Do not modify vertex positions.
- None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
-
set_url
(url)¶ Set the url for the artist.
Parameters: - urlstr
-
set_urls
(urls)¶ Parameters: - urlslist of str or None
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
-
set_visible
(b)¶ Set the artist's visibility.
Parameters: - bbool
-
set_zorder
(level)¶ Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters: - levelfloat
-
property
stale
¶ Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
-
property
sticky_edges
¶ x
andy
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.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
-
to_rgba
(x, alpha=None, bytes=False, norm=True)¶ Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
-
update
(props)¶ Update this artist's properties from the dict props.
Parameters: - propsdict
-
property
update_dict
¶
-
update_from
(other)¶ Copy properties from other to self.
-
update_scalarmappable
()¶ Update colors from the scalar mappable array, if it is not None.
-
zorder
= 0¶
-
class
matplotlib.collections.
TriMesh
(triangulation, **kwargs)[source]¶ Bases:
matplotlib.collections.Collection
Class for the efficient drawing of a triangular mesh using Gouraud shading.
A triangular mesh is a
Triangulation
object.Parameters: - edgecolorscolor or list of colors, default:
rcParams["patch.edgecolor"]
(default:'black'
) Edge color for each patch making up the collection. The special value 'face' can be passed to make the edgecolor match the facecolor.
- facecolorscolor or list of colors, default:
rcParams["patch.facecolor"]
(default:'C0'
) Face color for each patch making up the collection.
- linewidthsfloat or list of floats, default:
rcParams["patch.linewidth"]
(default:1.0
) Line width for each patch making up the collection.
- linestylesstr or tuple or list thereof, default: 'solid'
Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:
(offset, onoffseq),
where onoffseq is an even length tuple of on and off ink lengths in points. For examples, see Linestyles.
- capstylestr, default:
rcParams["patch.capstyle"]
Style to use for capping lines for all paths in the collection. See Join styles and cap styles for a demonstration of each of the allowed values.
- joinstylestr, default:
rcParams["patch.joinstyle"]
Style to use for joining lines for all paths in the collection. See Join styles and cap styles for a demonstration of each of the allowed values.
- antialiasedsbool or list of bool, default:
rcParams["patch.antialiased"]
(default:True
) Whether each pach in the collection should be drawn with antialiasing.
- offsets(float, float) or list thereof, default: (0, 0)
A vector by which to translate each patch after rendering (default is no translation). The translation is performed in screen (pixel) coordinates (i.e. after the Artist's transform is applied).
- transOffset
Transform
, default:IdentityTransform
A single transform which will be applied to each offsets vector before it is used.
- offset_position{'screen' (default), 'data' (deprecated)}
If set to 'data' (deprecated), offsets will be treated as if it is in data coordinates instead of in screen coordinates.
- norm
Normalize
, optional Forwarded to
ScalarMappable
. The default ofNone
means that the first draw call will setvmin
andvmax
using the minimum and maximum values of the data.- cmap
Colormap
, optional Forwarded to
ScalarMappable
. The default ofNone
will result inrcParams["image.cmap"]
(default:'viridis'
) being used.- hatchstr, optional
Hatching pattern to use in filled paths, if any. Valid strings are ['/', '', '|', '-', '+', 'x', 'o', 'O', '.', '*']. See Hatch Demo for the meaning of each hatch type.
- pickradiusfloat, default: 5.0
If
pickradius <= 0
, thenCollection.contains
will returnTrue
whenever the test point is inside of one of the 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 width2*pickradius
following any of the Paths in the Collection.- urlslist of str, default: None
A URL for each patch to link to once drawn. Currently only works for the SVG backend. See Hyperlinks for examples.
- zorderfloat, default: 1
The drawing order, shared by all Patches in the Collection. See Zorder Demo for all defaults and examples.
-
add_callback
(func)¶ Add a callback function that will be called whenever one of the
Artist
's properties changes.Parameters: - funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling
Artist
. Return values may exist but are ignored.
Returns: - int
The observer id associated with the callback. This id can be used for removing the callback with
remove_callback
later.
See also
-
add_checker
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
autoscale
()¶ Autoscale the scalar limits on the norm instance using the current array
-
autoscale_None
()¶ Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
-
changed
()¶ Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
-
check_update
(checker)¶ [Deprecated]
Notes
Deprecated since version 3.3:
-
contains
(mouseevent)¶ Test whether the mouse event occurred in the collection.
Returns
bool, dict(ind=itemlist)
, where every item in itemlist contains the event.
-
static
convert_mesh_to_paths
(tri)[source]¶ Convert a given mesh into a sequence of
Path
objects.This function is primarily of use to implementers of backends that do not directly support meshes.
-
convert_xunits
(x)¶ Convert x using the unit type of the xaxis.
If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.
-
convert_yunits
(y)¶ Convert y using the unit type of the yaxis.
If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.
-
draw
(renderer)[source]¶ Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visible
returns False).Parameters: - renderer
RendererBase
subclass.
Notes
This method is overridden in the Artist subclasses.
- renderer
-
findobj
(match=None, include_self=True)¶ Find artist objects.
Recursively find all
Artist
instances contained in the artist.Parameters: - match
A filter criterion for the matches. This can be
- None: Return all objects contained in artist.
- A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True. - A class instance: e.g.,
Line2D
. The result will only contain artists of this class or its subclasses (isinstance
check).
- include_selfbool
Include self in the list to be checked for a match.
Returns: - list of
Artist
-
format_cursor_data
(data)¶ 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.
See also
-
get_agg_filter
()¶ Return filter function to be used for agg filter.
-
get_alpha
()¶ Return the alpha value used for blending - not supported on all backends.
-
get_animated
()¶ Return whether the artist is animated.
-
get_array
()¶ Return the data array.
-
get_capstyle
()¶
-
get_clim
()¶ Return the values (min, max) that are mapped to the colormap limits.
-
get_clip_box
()¶ Return the clipbox.
-
get_clip_on
()¶ Return whether the artist uses clipping.
-
get_clip_path
()¶ Return the clip path.
-
get_contains
()¶ [Deprecated] Return the custom contains function of the artist if set, or None.
See also
Notes
Deprecated since version 3.3.
-
get_cursor_data
(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.Parameters: See also
-
get_dashes
()¶ Alias for
get_linestyle
.
-
get_datalim
(transData)¶
-
get_ec
()¶ Alias for
get_edgecolor
.
-
get_edgecolor
()¶
-
get_edgecolors
()¶ Alias for
get_edgecolor
.
-
get_facecolor
()¶
-
get_facecolors
()¶ Alias for
get_facecolor
.
-
get_fc
()¶ Alias for
get_facecolor
.
-
get_fill
()¶ Return whether fill is set.
-
get_gid
()¶ Return the group id.
-
get_hatch
()¶ Return the current hatching pattern.
-
get_in_layout
()¶ Return boolean flag,
True
if artist is included in layout calculations.E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.
-
get_joinstyle
()¶
-
get_label
()¶ Return the label used for this artist in the legend.
-
get_linestyle
()¶
-
get_linestyles
()¶ Alias for
get_linestyle
.
-
get_linewidth
()¶
-
get_linewidths
()¶ Alias for
get_linewidth
.
-
get_ls
()¶ Alias for
get_linestyle
.
-
get_lw
()¶ Alias for
get_linewidth
.
-
get_offset_position
()¶ [Deprecated] Return how offsets are applied for the collection. If offset_position is 'screen', the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Notes
Deprecated since version 3.3.
-
get_offset_transform
()¶
-
get_offsets
()¶ Return the offsets for the collection.
-
get_path_effects
()¶
-
get_picker
()¶ Return the picking behavior of the artist.
The possible values are described in
set_picker
.See also
-
get_pickradius
()¶
-
get_rasterized
()¶ Return whether the artist is to be rasterized.
-
get_sketch_params
()¶ Return the sketch parameters for the artist.
Returns: - tuple or None
A 3-tuple with the following elements:
- scale: The amplitude of the wiggle perpendicular to the source line.
- length: The length of the wiggle along the line.
- randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
-
get_tightbbox
(renderer)¶ Like
Artist.get_window_extent
, but includes any clipping.Parameters: - renderer
RendererBase
subclass renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer()
)
Returns: Bbox
The enclosing bounding box (in figure pixel coordinates).
- renderer
-
get_transformed_clip_path_and_affine
()¶ Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
-
get_transforms
()¶
-
get_url
()¶ Return the url.
-
get_urls
()¶ Return a list of URLs, one for each element of the collection.
The list contains None for elements without a URL. See Hyperlinks for an example.
-
get_visible
()¶ Return the visibility.
-
get_window_extent
(renderer)¶ Get the axes bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
-
get_zorder
()¶ Return the artist's zorder.
-
have_units
()¶ Return True if units are set on any axis.
-
is_transform_set
()¶ Return whether the Artist has an explicitly set transform.
This is True after
set_transform
has been called.
-
property
mouseover
¶ If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also
get_cursor_data()
,ToolCursorPosition
andNavigationToolbar2
.
-
pchanged
()¶ Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
-
pick
(mouseevent)¶ Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
-
pickable
()¶ Return whether the artist is pickable.
See also
-
properties
()¶ Return a dictionary of all the properties of the artist.
-
remove
()¶ Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with
FigureCanvasBase.draw_idle
. Callrelim
to update the axes limits if desired.Note:
relim
will not see collections even if the collection was added to the axes with autolim = True.Note: there is no support for removing the artist's legend entry.
-
remove_callback
(oid)¶ Remove a callback based on its observer id.
See also
-
set
(**kwargs)¶ A property batch setter. Pass kwargs to set properties.
-
set_aa
(aa)¶ Alias for
set_antialiased
.
-
set_agg_filter
(filter_func)¶ Set the agg filter.
Parameters: - filter_funccallable
A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.
-
set_alpha
(alpha)¶ Set the alpha value used for blending - not supported on all backends.
Parameters: - alphafloat or None
-
set_animated
(b)¶ Set the artist's animation state.
Parameters: - bbool
-
set_antialiased
(aa)¶ Set the antialiasing state for rendering.
Parameters: - aabool or list of bools
-
set_antialiaseds
(aa)¶ Alias for
set_antialiased
.
-
set_array
(A)¶ Set the image array from numpy array A.
Parameters: - Andarray
-
set_capstyle
(cs)¶ Set the capstyle for the collection (for all its elements).
Parameters: - cs{'butt', 'round', 'projecting'}
The capstyle.
-
set_clim
(vmin=None, vmax=None)¶ Set the norm limits for image scaling.
Parameters: - vmin, vmaxfloat
The limits.
The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
-
set_clip_on
(b)¶ Set whether the artist uses clipping.
When False artists will be visible outside of the axes which can lead to unexpected results.
Parameters: - bbool
-
set_clip_path
(path, transform=None)¶ Set the artist's clip path.
Parameters: - path
Patch
orPath
orTransformedPath
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
Transform
, optional Only used if path is a
Path
, in which case the givenPath
is converted to aTransformedPath
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 toNone
.For technical reasons (support of
set
), a tuple (path, transform) is also accepted as a single positional parameter.- path
-
set_color
(c)¶ Set both the edgecolor and the facecolor.
Parameters: - ccolor or list of rgba tuples
See also
Collection.set_facecolor
,Collection.set_edgecolor
- For setting the edge or face color individually.
-
set_contains
(picker)¶ [Deprecated] Define a custom contains test for the artist.
The provided callable replaces the default
contains
method of the artist.Parameters: - pickercallable
A custom picker function to evaluate if an event is within the artist. The function must have the signature:
def contains(artist: Artist, event: MouseEvent) -> bool, dict
that returns:
- a bool indicating if the event is within the artist
- a dict of additional information. The dict should at least
return the same information as the default
contains()
implementation of the respective artist, but may provide additional information.
Notes
Deprecated since version 3.3.
-
set_dashes
(ls)¶ Alias for
set_linestyle
.
-
set_ec
(c)¶ Alias for
set_edgecolor
.
-
set_edgecolor
(c)¶ Set the edgecolor(s) of the collection.
Parameters: - ccolor or list of colors or 'face'
The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor.
-
set_edgecolors
(c)¶ Alias for
set_edgecolor
.
-
set_facecolor
(c)¶ Set the facecolor(s) of the collection. c can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence.
If c is 'none', the patch will not be filled.
Parameters: - ccolor or list of colors
-
set_facecolors
(c)¶ Alias for
set_facecolor
.
-
set_fc
(c)¶ Alias for
set_facecolor
.
-
set_gid
(gid)¶ Set the (group) id for the artist.
Parameters: - gidstr
-
set_hatch
(hatch)¶ Set the hatching pattern
hatch can be one of:
/ - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member.
Parameters: - hatch{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
-
set_in_layout
(in_layout)¶ Set if artist is to be included in layout calculations, E.g. Constrained Layout Guide,
Figure.tight_layout()
, andfig.savefig(fname, bbox_inches='tight')
.Parameters: - in_layoutbool
-
set_joinstyle
(js)¶ Set the joinstyle for the collection (for all its elements).
Parameters: - js{'miter', 'round', 'bevel'}
The joinstyle.
-
set_label
(s)¶ Set a label that will be displayed in the legend.
Parameters: - sobject
s will be converted to a string by calling
str
.
-
set_linestyle
(ls)¶ Set the linestyle(s) for the collection.
linestyle description '-'
or'solid'
solid line '--'
or'dashed'
dashed line '-.'
or'dashdot'
dash-dotted line ':'
or'dotted'
dotted line Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq),
where
onoffseq
is an even length tuple of on and off ink in points.Parameters: - lsstr or tuple or list thereof
Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See
Line2D.set_linestyle
for a complete description.
-
set_linestyles
(ls)¶ Alias for
set_linestyle
.
-
set_linewidth
(lw)¶ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
Parameters: - lwfloat or list of floats
-
set_linewidths
(lw)¶ Alias for
set_linewidth
.
-
set_ls
(ls)¶ Alias for
set_linestyle
.
-
set_lw
(lw)¶ Alias for
set_linewidth
.
-
set_norm
(norm)¶ Set the normalization instance.
Parameters: - norm
Normalize
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.
- norm
-
set_offset_position
(offset_position)¶ [Deprecated] Set how offsets are applied. If offset_position is 'screen' (default) the offset is applied after the master transform has been applied, that is, the offsets are in screen coordinates. If offset_position is 'data', the offset is applied before the master transform, i.e., the offsets are in data coordinates.
Parameters: - offset_position{'screen', 'data'}
Notes
Deprecated since version 3.3.
-
set_offsets
(offsets)¶ Set the offsets for the collection.
Parameters: - offsetsarray-like (N, 2) or (2,)
-
set_path_effects
(path_effects)¶ Set the path effects.
Parameters: - path_effects
AbstractPathEffect
- path_effects
-
set_picker
(picker)¶ Define the picking behavior of the artist.
Parameters: - pickerNone or bool or callable
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A 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.
deprecated: For
Line2D
only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. UseLine2D.set_pickradius
instead.
-
set_pickradius
(pr)¶ Set the pick radius used for containment tests.
Parameters: - dfloat
Pick radius, in points.
-
set_rasterized
(rasterized)¶ Force rasterized (bitmap) drawing in vector backend output.
Defaults to None, which implies the backend's default behavior.
Parameters: - rasterizedbool or None
-
set_sketch_params
(scale=None, length=None, randomness=None)¶ Sets the sketch parameters.
Parameters: - scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is
None
, or not provided, no sketch filter will be provided.- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
-
set_snap
(snap)¶ Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters: - snapbool or None
Possible values:
- True: Snap vertices to the nearest pixel center.
- False: Do not modify vertex positions.
- None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
-
set_url
(url)¶ Set the url for the artist.
Parameters: - urlstr
-
set_urls
(urls)¶ Parameters: - urlslist of str or None
Notes
URLs are currently only implemented by the SVG backend. They are ignored by all other backends.
-
set_visible
(b)¶ Set the artist's visibility.
Parameters: - bbool
-
set_zorder
(level)¶ Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters: - levelfloat
-
property
stale
¶ Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
-
property
sticky_edges
¶ x
andy
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.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
-
to_rgba
(x, alpha=None, bytes=False, norm=True)¶ Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
-
update
(props)¶ Update this artist's properties from the dict props.
Parameters: - propsdict
-
property
update_dict
¶
-
update_from
(other)¶ Copy properties from other to self.
-
update_scalarmappable
()¶ Update colors from the scalar mappable array, if it is not None.
-
zorder
= 0¶
- edgecolorscolor or list of colors, default: