egttools.plotting.indicators.LineCollection

class LineCollection(segments, *, zorder=2, **kwargs)[source]

Bases: Collection

Represents a sequence of .Line2Ds that should be drawn together.

This class extends .Collection to represent a sequence of .Line2Ds instead of just a sequence of .Patchs. Just as in .Collection, each property of a LineCollection may be either a single value or a list of values. This list is then used cyclically for each element of the LineCollection, so the property of the ith element of the collection is:

prop[i % len(prop)]

The properties of each member of a LineCollection default to their values in :rc:`lines.*` instead of :rc:`patch.*`, and the property colors is added in place of edgecolors.

Parameters:
  • segments (Sequence[ArrayLike]) –

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

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

    Each line can contain a different number of points.

  • linewidths (float or list of float, default: :rc:`lines.linewidth`) – The width of each line in points.

  • colors (:mpltype:`color` or list of color, default: :rc:`lines.color`) – A sequence of RGBA tuples (e.g., arbitrary color strings, etc, not allowed).

  • antialiaseds (bool or list of bool, default: :rc:`lines.antialiased`) – Whether to use antialiasing for each line.

  • zorder (float) – zorder of the lines once drawn.

  • facecolors (:mpltype:`color` or list of :mpltype:`color`, default: ‘none’) – When setting facecolors, each line is interpreted as a boundary for an area, implicitly closing the path from the last point to the first point. The enclosed area is filled with facecolor. In order to manually specify what should count as the “interior” of each line, please use .PathCollection instead, where the “interior” can be specified by appropriate usage of ~.path.Path.CLOSEPOLY.

  • **kwargs – Forwarded to .Collection.

Methods

add_callback

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

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.

contains

Test whether the mouse event occurred in the collection.

convert_xunits

Convert x using the unit type of the xaxis.

convert_yunits

Convert y using the unit type of the yaxis.

draw

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

findobj

Find artist objects.

format_cursor_data

Return a string representation of data.

get_aa

Alias for get_antialiased.

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_antialiased

Get the antialiasing state for rendering.

get_antialiaseds

Alias for get_antialiased.

get_array

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

get_capstyle

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

get_children

Return a list of the child .Artists of this .Artist.

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_cmap

Return the .Colormap instance.

get_color

get_colors

get_cursor_data

Return the cursor data for a given event.

get_dashes

Alias for get_linestyle.

get_datalim

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_figure

Return the .Figure or .SubFigure instance the artist belongs to.

get_fill

Return whether face is colored.

get_gapcolor

get_gid

Return the group id.

get_hatch

Return the current hatching pattern.

get_hatch_linewidth

Return the hatch linewidth.

get_hatchcolor

get_in_layout

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

get_joinstyle

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

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_mouseover

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

get_offset_transform

Return the .Transform instance used by this artist offset.

get_offsets

Return the offsets for the collection.

get_path_effects

get_paths

get_picker

Return the picking behavior of the artist.

get_pickradius

get_rasterized

Return whether the artist is to be rasterized.

get_segments

get_sketch_params

Return the sketch parameters for the artist.

get_snap

Return the snap setting.

get_tightbbox

Get the artist's bounding box in display space, taking clipping into account.

get_transOffset

Alias for get_offset_transform.

get_transform

Return the .Transform instance used by this artist.

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.

get_visible

Return the visibility.

get_window_extent

Get the artist's bounding box in display space, ignoring clipping.

get_zorder

Return the artist's zorder.

have_units

Return whether units are set on any axis.

is_transform_set

Return whether the Artist has an explicitly set transform.

pchanged

Call all of the registered callbacks.

pick

Process a pick event.

pickable

Return whether the artist is pickable.

properties

Return a dictionary of all the properties of the artist.

remove

Remove the artist from the figure if possible.

remove_callback

Remove a callback based on its observer id.

set

Set multiple properties at once.

set_aa

Alias for set_antialiased.

set_agg_filter

Set the agg filter.

set_alpha

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

set_animated

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

set_antialiased

Set the antialiasing state for rendering.

set_antialiaseds

Alias for set_antialiased.

set_array

Set the value array from array-like A.

set_capstyle

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

set_clim

Set the norm limits for image scaling.

set_clip_box

Set the artist's clip .Bbox.

set_clip_on

Set whether the artist uses clipping.

set_clip_path

Set the artist's clip path.

set_cmap

Set the colormap for luminance data.

set_color

Set the edgecolor(s) of the LineCollection.

set_colors

Set the edgecolor(s) of the LineCollection.

set_dashes

Alias for set_linestyle.

set_ec

Alias for set_edgecolor.

set_edgecolor

Set the edgecolor(s) of the collection.

set_edgecolors

Alias for set_edgecolor.

set_facecolor

Set the facecolor(s) of the collection.

set_facecolors

Alias for set_facecolor.

set_fc

Alias for set_facecolor.

set_figure

Set the .Figure or .SubFigure instance the artist belongs to.

set_gapcolor

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

set_gid

Set the (group) id for the artist.

set_hatch

Set the hatching pattern

set_hatch_linewidth

Set the hatch linewidth.

set_hatchcolor

Set the hatchcolor(s) of the collection.

set_in_layout

Set if artist is to be included in layout calculations, E.g.

set_joinstyle

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

set_label

Set a label that will be displayed in the legend.

set_linestyle

Set the linestyle(s) for the collection.

set_linestyles

Alias for set_linestyle.

set_linewidth

Set the linewidth(s) for the collection.

set_linewidths

Alias for set_linewidth.

set_ls

Alias for set_linestyle.

set_lw

Alias for set_linewidth.

set_mouseover

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

set_norm

Set the normalization instance.

set_offset_transform

Set the artist offset transform.

set_offsets

Set the offsets for the collection.

set_path_effects

Set the path effects.

set_paths

set_picker

Define the picking behavior of the artist.

set_pickradius

Set the pick radius used for containment tests.

set_rasterized

Force rasterized (bitmap) drawing for vector graphics output.

set_segments

set_sketch_params

Set the sketch parameters.

set_snap

Set the snapping behavior.

set_transOffset

Alias for set_offset_transform.

set_transform

Set the artist transform.

set_url

Set the url for the artist.

set_urls

set_verts

set_visible

Set the artist's visibility.

set_zorder

Set the zorder for the artist.

to_rgba

Return a normalized RGBA array corresponding to x.

update

[Discouraged] Update this artist's properties from the dictionary props.

update_from

Copy properties from other to self.

update_scalarmappable

Update colors from the scalar mappable array, if any.

Attributes

axes

The ~.axes.Axes instance the artist resides in, or None.

cmap

colorbar

The last colorbar associated with this object.

colorizer

figure

The (Sub)Figure that the artist is on.

mouseover

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

norm

stale

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

sticky_edges

x and y sticky edge lists for autoscaling.

zorder

classmethod __init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__init__(segments, *, zorder=2, **kwargs)[source]
Parameters:
  • segments (Sequence[ArrayLike]) –

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

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

    Each line can contain a different number of points.

  • linewidths (float or list of float, default: :rc:`lines.linewidth`) – The width of each line in points.

  • colors (:mpltype:`color` or list of color, default: :rc:`lines.color`) – A sequence of RGBA tuples (e.g., arbitrary color strings, etc, not allowed).

  • antialiaseds (bool or list of bool, default: :rc:`lines.antialiased`) – Whether to use antialiasing for each line.

  • zorder (float) – zorder of the lines once drawn.

  • facecolors (:mpltype:`color` or list of :mpltype:`color`, default: ‘none’) – When setting facecolors, each line is interpreted as a boundary for an area, implicitly closing the path from the last point to the first point. The enclosed area is filled with facecolor. In order to manually specify what should count as the “interior” of each line, please use .PathCollection instead, where the “interior” can be specified by appropriate usage of ~.path.Path.CLOSEPOLY.

  • **kwargs – Forwarded to .Collection.

add_callback(func)

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

Parameters:

func (Callable[[Artist], Any]) –

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:

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

Return type:

int

See also

remove_callback

autoscale()

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

Return type:

None

autoscale_None()

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

Return type:

None

changed()

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

Return type:

None

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 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 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 (~matplotlib.backend_bases.RendererBase subclass.)

Notes

This method is overridden in the Artist subclasses.

findobj(match=None, include_self=True)

Find artist objects.

Recursively find all .Artist instances contained in the artist.

Parameters:
  • match (None | Callable[[Artist], bool] | type[_T_Artist]) –

    A filter criterion for the matches. This can be

    • None: Return all objects contained in artist.

    • A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.

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

  • include_self (bool) – Include self in the list to be checked for a match.

Return type:

list[Artist] | list[_T_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, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar’s formatter.

See also

get_cursor_data

Return type:

str

get_aa()

Alias for get_antialiased.

Return type:

NDArray[bool]

get_agg_filter()

Return filter function to be used for agg filter.

Return type:

Callable[[ArrayLike, float], tuple[ndarray, float, float]] | None

get_alpha()

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

Return type:

float | None

get_animated()

Return whether the artist is animated.

Return type:

bool

get_antialiased()

Get the antialiasing state for rendering.

Return type:

NDArray[bool]

get_antialiaseds()

Alias for get_antialiased.

Return type:

NDArray[bool]

get_array()

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

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

Return type:

ndarray | None

get_capstyle()

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

Return type:

Optional[Literal['butt', 'projecting', 'round']]

get_children()

Return a list of the child .Artists of this .Artist.

Return type:

list[Artist]

get_clim()

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

Return type:

tuple[float, float]

get_clip_box()

Return the clipbox.

Return type:

Bbox | None

get_clip_on()

Return whether the artist uses clipping.

Return type:

bool

get_clip_path()

Return the clip path.

Return type:

Patch | Path | TransformedPath | TransformedPatchPath | None

get_cmap()

Return the .Colormap instance.

Return type:

Colormap

get_color()[source]
Return type:

tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]

get_colors()
Return type:

tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]

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:

event (MouseEvent)

Return type:

Any

get_dashes()

Alias for get_linestyle.

Return type:

Union[Literal['-', 'solid', '--', 'dashed', '-.', 'dashdot', ':', 'dotted', '', 'none', ' ', 'None'], tuple[float, Sequence[float]], Sequence[Union[Literal['-', 'solid', '--', 'dashed', '-.', 'dashdot', ':', 'dotted', '', 'none', ' ', 'None'], tuple[float, Sequence[float]]]]]

get_datalim(transData)
Return type:

Bbox

get_ec()

Alias for get_edgecolor.

Return type:

tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]

get_edgecolor()
Return type:

tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]

get_edgecolors()

Alias for get_edgecolor.

Return type:

tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]

get_facecolor()
Return type:

tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]

get_facecolors()

Alias for get_facecolor.

Return type:

tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]

get_fc()

Alias for get_facecolor.

Return type:

tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]

get_figure(root=False)

Return the .Figure or .SubFigure instance the artist belongs to.

Parameters:

root (Union[Literal[True], Literal[False], bool]) – If False, return the (Sub)Figure this artist is on. If True, return the root Figure for a nested tree of SubFigures.

Return type:

Figure | None | SubFigure

get_fill()

Return whether face is colored.

Return type:

bool

get_gapcolor()[source]
Return type:

tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]] | None

get_gid()

Return the group id.

Return type:

str | None

get_hatch()

Return the current hatching pattern.

Return type:

str

get_hatch_linewidth()

Return the hatch linewidth.

Return type:

float

get_hatchcolor()
Return type:

tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]

get_in_layout()

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

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

Return type:

bool

get_joinstyle()

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

Return type:

Optional[Literal['miter', 'round', 'bevel']]

get_label()

Return the label used for this artist in the legend.

Return type:

object

get_linestyle()
Return type:

Union[Literal['-', 'solid', '--', 'dashed', '-.', 'dashdot', ':', 'dotted', '', 'none', ' ', 'None'], tuple[float, Sequence[float]], Sequence[Union[Literal['-', 'solid', '--', 'dashed', '-.', 'dashdot', ':', 'dotted', '', 'none', ' ', 'None'], tuple[float, Sequence[float]]]]]

get_linestyles()

Alias for get_linestyle.

Return type:

Union[Literal['-', 'solid', '--', 'dashed', '-.', 'dashdot', ':', 'dotted', '', 'none', ' ', 'None'], tuple[float, Sequence[float]], Sequence[Union[Literal['-', 'solid', '--', 'dashed', '-.', 'dashdot', ':', 'dotted', '', 'none', ' ', 'None'], tuple[float, Sequence[float]]]]]

get_linewidth()
Return type:

float | Sequence[float]

get_linewidths()

Alias for get_linewidth.

Return type:

float | Sequence[float]

get_ls()

Alias for get_linestyle.

Return type:

Union[Literal['-', 'solid', '--', 'dashed', '-.', 'dashdot', ':', 'dotted', '', 'none', ' ', 'None'], tuple[float, Sequence[float]], Sequence[Union[Literal['-', 'solid', '--', 'dashed', '-.', 'dashdot', ':', 'dotted', '', 'none', ' ', 'None'], tuple[float, Sequence[float]]]]]

get_lw()

Alias for get_linewidth.

Return type:

float | Sequence[float]

get_mouseover()

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

Return type:

bool

get_offset_transform()

Return the .Transform instance used by this artist offset.

Return type:

Transform

get_offsets()

Return the offsets for the collection.

Return type:

ArrayLike

get_path_effects()
Return type:

list[AbstractPathEffect]

get_paths()
Return type:

Sequence[Path]

get_picker()

Return the picking behavior of the artist.

The possible values are described in .Artist.set_picker.

See also

Artist.set_picker, Artist.pickable, Artist.pick

Return type:

None | bool | float | Callable[[Artist, MouseEvent], tuple[bool, dict[Any, Any]]]

get_pickradius()
Return type:

float

get_rasterized()

Return whether the artist is to be rasterized.

Return type:

bool

get_segments()[source]
Returns:

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

Return type:

list[ndarray]

get_sketch_params()

Return the sketch parameters for the artist.

Returns:

A 3-tuple with the following elements:

  • scale: The amplitude of the wiggle perpendicular to the source line.

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

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

Returns None if no sketch parameters were set.

Return type:

tuple[float, float, float] | None

get_snap()

Return the snap setting.

See .set_snap for details.

Return type:

bool | None

get_tightbbox(renderer=None)

Get the artist’s bounding box in display space, taking clipping into account.

Parameters:

renderer (RendererBase | None) – Renderer used to draw the figure (i.e. fig.canvas.get_renderer()).

Returns:

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

Return type:

Bbox | None

See also

Artist.get_window_extent

Get the artist bounding box, ignoring clipping.

get_transOffset()

Alias for get_offset_transform.

Return type:

Transform

get_transform()

Return the .Transform instance used by this artist.

Return type:

Transform

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.

Return type:

tuple[None, None] | tuple[Path, Transform]

get_transforms()
Return type:

Sequence[Transform]

get_url()

Return the url.

Return type:

str | None

get_urls()

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

The list contains None for elements without a URL. See /gallery/misc/hyperlinks_sgskip for an example.

Return type:

Sequence[str | None]

get_visible()

Return the visibility.

Return type:

bool

get_window_extent(renderer=None)

Get the artist’s bounding box in display space, ignoring clipping.

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

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

Warning

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

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

To get accurate results you may need to manually call ~.Figure.savefig or ~.Figure.draw_without_rendering to have Matplotlib compute the rendered size.

Parameters:

renderer (~matplotlib.backend_bases.RendererBase, optional) – Renderer used to draw the figure (i.e. fig.canvas.get_renderer()).

See also

Artist.get_tightbbox

Get the artist bounding box, taking clipping into account.

get_zorder()

Return the artist’s zorder.

Return type:

float

have_units()

Return whether units are set on any axis.

Return type:

bool

is_transform_set()

Return whether the Artist has an explicitly set transform.

This is True after .set_transform has been called.

Return type:

bool

pchanged()

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

Return type:

None

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

Artist.set_picker, Artist.get_picker, Artist.pickable

Return type:

None

pickable()

Return whether the artist is pickable.

See also

Artist.set_picker, Artist.get_picker, Artist.pick

Return type:

bool

properties()

Return a dictionary of all the properties of the artist.

Return type:

dict[str, Any]

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. Call ~.axes.Axes.relim to update the Axes limits if desired.

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

Return type:

None

remove_callback(oid)

Remove a callback based on its observer id.

See also

add_callback

Return type:

None

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

Set multiple properties at once.

a.set(a=A, b=B, c=C)

is equivalent to

a.set_a(A)
a.set_b(B)
a.set_c(C)

In addition to the full property names, aliases are also supported, e.g. set(lw=2) is equivalent to set(linewidth=2), but it is an error to pass both simultaneously.

The order of the individual setter calls matches the order of parameters in set(). However, most properties do not depend on each other so that order is rarely relevant.

Supported properties are

Properties:

agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: unknown animated: bool antialiased or aa or antialiaseds: bool or list of bools array: array-like or None capstyle: .CapStyle or {‘butt’, ‘projecting’, ‘round’} clim: (vmin: float, vmax: float) clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None cmap: .Colormap or str or None color: :mpltype:`color` or list of :mpltype:`color` colors: :mpltype:`color` or list of :mpltype:`color` edgecolor or ec or edgecolors: :mpltype:`color` or list of :mpltype:`color` or ‘face’ facecolor or facecolors or fc: :mpltype:`color` or list of :mpltype:`color` figure: ~matplotlib.figure.Figure or ~matplotlib.figure.SubFigure gapcolor: :mpltype:`color` or list of :mpltype:`color` or None gid: str hatch: {‘/’, ‘\’, ‘|’, ‘-’, ‘+’, ‘x’, ‘o’, ‘O’, ‘.’, ‘*’} hatch_linewidth: unknown hatchcolor: :mpltype:`color` or list of :mpltype:`color` or ‘edge’ in_layout: bool joinstyle: .JoinStyle or {‘miter’, ‘round’, ‘bevel’} label: object linestyle or dashes or linestyles or ls: {‘-’, ‘–’, ‘-.’, ‘:’, ‘’, …} or (offset, on-off-seq) or list thereof linewidth or linewidths or lw: float or list of floats mouseover: bool norm: .Normalize or str or None offset_transform or transOffset: .Transform offsets: (N, 2) or (2,) array-like path_effects: list of .AbstractPathEffect paths: unknown picker: None or bool or float or callable pickradius: float rasterized: bool segments: unknown sketch_params: (scale: float, length: float, randomness: float) snap: bool or None transform: ~matplotlib.transforms.Transform url: str urls: list of str or None verts: unknown visible: bool zorder: float

set_aa(aa)

Alias for set_antialiased.

Return type:

None

set_agg_filter(filter_func)

Set the agg filter.

Parameters:

filter_func (Callable[[ArrayLike, float], tuple[ndarray, float, float]] | None) –

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

Return type:

None

set_alpha(alpha)[source]

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

Parameters:

alpha (array-like or float or None) – All values must be within the 0-1 range, inclusive. Masked values and nans are not supported.

set_animated(b)

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

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

See also matplotlib.animation and blitting.

Parameters:

b (bool)

Return type:

None

set_antialiased(aa)

Set the antialiasing state for rendering.

Parameters:

aa (bool | Sequence[bool])

Return type:

None

set_antialiaseds(aa)

Alias for set_antialiased.

Return type:

None

set_array(A)

Set the value array from array-like A.

Parameters:

A (ArrayLike | None) –

The values that are mapped to colors.

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

Return type:

None

set_capstyle(cs)

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

Parameters:

cs (Union[CapStyle, Literal['butt', 'projecting', 'round']])

Return type:

None

set_clim(vmin=None, vmax=None)

Set the norm limits for image scaling.

Parameters:
  • vmin (float | tuple[float, float] | None) –

    The limits.

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

  • vmax (float | None) –

    The limits.

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

Return type:

None

set_clip_box(clipbox)

Set the artist’s clip .Bbox.

Parameters:

clipbox (BboxBase | None) – Will typically be created from a .TransformedBbox. For instance, TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes) is the default clipping for an artist added to an Axes.

Return type:

None

set_clip_on(b)

Set whether the artist uses clipping.

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

Parameters:

b (bool)

Return type:

None

set_clip_path(path, transform=None)

Set the artist’s clip path.

Parameters:
  • path (Patch | Path | TransformedPath | TransformedPatchPath | 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 | None) – Only used if path is a .Path, in which case the given .Path is converted to a .TransformedPath using transform.

Return type:

None

Notes

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

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

set_cmap(cmap)

Set the colormap for luminance data.

Parameters:

cmap (str | Colormap)

Return type:

None

set_color(c)[source]

Set the edgecolor(s) of the LineCollection.

Parameters:

c (tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]) – Single color (all lines have same color), or a sequence of RGBA tuples; if it is a sequence the lines will cycle through the sequence.

Return type:

None

set_colors(c)

Set the edgecolor(s) of the LineCollection.

Parameters:

c (tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]) – Single color (all lines have same color), or a sequence of RGBA tuples; if it is a sequence the lines will cycle through the sequence.

Return type:

None

set_dashes(ls)

Alias for set_linestyle.

Return type:

None

set_ec(c)

Alias for set_edgecolor.

Return type:

None

set_edgecolor(c)

Set the edgecolor(s) of the collection.

Parameters:

c (tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]) – The collection edgecolor(s). If a sequence, the patches cycle through it. If ‘face’, match the facecolor.

Return type:

None

set_edgecolors(c)

Alias for set_edgecolor.

Return type:

None

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:

c (tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]])

Return type:

None

set_facecolors(c)

Alias for set_facecolor.

Return type:

None

set_fc(c)

Alias for set_facecolor.

Return type:

None

set_figure(fig)

Set the .Figure or .SubFigure instance the artist belongs to.

Warning

This function should typically not be called by users.

This is a low-level API and only modifies the internal state of the Artist. Only modifying this is not enough and will typically lead to an inconsistent state, because the state of the figure has to be changed as well.

Users should typically instead call one of the high-level APIs, i.e. .Figure.add_artist or one of the Axes methods axes-api-adding-artists.

Parameters:

fig (Figure | SubFigure)

Return type:

None

set_gapcolor(gapcolor)[source]

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

Note

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

This functionality is experimental and may change.

Parameters:

gapcolor (tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]] | None) – The color with which to fill the gaps. If None, the gaps are unfilled.

Return type:

None

set_gid(gid)

Set the (group) id for the artist.

Parameters:

gid (str | None)

Return type:

None

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.

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 (str)

Return type:

None

set_hatch_linewidth(lw)

Set the hatch linewidth.

Return type:

None

set_hatchcolor(c)

Set the hatchcolor(s) of the collection.

Parameters:

c (Union[tuple[float, float, float], str, tuple[float, float, float, float], tuple[tuple[float, float, float] | str, float], tuple[tuple[float, float, float, float], float], Sequence[tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]], Literal['edge']]) – The collection hatchcolor(s). If a sequence, the patches cycle through it.

Return type:

None

set_in_layout(in_layout)

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

Parameters:

in_layout (bool)

Return type:

None

set_joinstyle(js)

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

Parameters:

js (Union[JoinStyle, Literal['miter', 'round', 'bevel']])

Return type:

None

set_label(s)

Set a label that will be displayed in the legend.

Parameters:

s (object) – s will be converted to a string by calling str.

Return type:

None

set_linestyle(ls)

Set the linestyle(s) for the collection.

Parameters:

ls (Union[Literal['-', 'solid', '--', 'dashed', '-.', 'dashdot', ':', 'dotted', '', 'none', ' ', 'None'], tuple[float, Sequence[float]], Sequence[Union[Literal['-', 'solid', '--', 'dashed', '-.', 'dashdot', ':', 'dotted', '', 'none', ' ', 'None'], tuple[float, Sequence[float]]]]]) –

If a list, the individual elements are assigned to the elements of the collection.

Possible values:

  • A string:

    linestyle

    description

    '-' or 'solid'

    solid line

    '--' or 'dashed'

    dashed line

    '-.' or 'dashdot'

    dash-dotted line

    ':' or 'dotted'

    dotted line

    '' or 'none' (discouraged: 'None', ' ')

    draw nothing

  • A tuple describing the start position and lengths of dashes and spaces:

    (offset, onoffseq)

    where

    • offset is a float specifying the offset (in points); i.e. how much is the dash pattern shifted.

    • onoffseq is a sequence of on and off ink in points. There can be arbitrary many pairs of on and off values.

    Example: The tuple (0, (10, 5, 1, 5)) means that the pattern starts at the beginning of the line. It draws a 10 point long dash, then a 5 point long space, then a 1 point long dash, followed by a 5 point long space, and then the pattern repeats.

For examples see /gallery/lines_bars_and_markers/linestyles.

Return type:

None

set_linestyles(ls)

Alias for set_linestyle.

Return type:

None

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:

lw (float | Sequence[float])

Return type:

None

set_linewidths(lw)

Alias for set_linewidth.

Return type:

None

set_ls(ls)

Alias for set_linestyle.

Return type:

None

set_lw(lw)

Alias for set_linewidth.

Return type:

None

set_mouseover(mouseover)

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

Parameters:

mouseover (bool)

Return type:

None

See also

get_cursor_data, ToolCursorPosition, NavigationToolbar2

set_norm(norm)

Set the normalization instance.

Parameters:

norm (Norm | str | None)

Return type:

None

Notes

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

set_offset_transform(offset_transform)

Set the artist offset transform.

Parameters:

offset_transform (Transform)

Return type:

None

set_offsets(offsets)

Set the offsets for the collection.

Parameters:

offsets (ArrayLike)

Return type:

None

set_path_effects(path_effects)

Set the path effects.

Parameters:

path_effects (list[AbstractPathEffect])

Return type:

None

set_paths(segments)
Return type:

None

set_picker(picker)

Define the picking behavior of the artist.

Parameters:

picker (None | bool | float | Callable[[Artist, MouseEvent], tuple[bool, dict[Any, Any]]]) –

This can be one of the following:

  • None: Picking is disabled for this artist (default).

  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.

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

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

    hit, props = picker(artist, mouseevent)
    

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

Return type:

None

set_pickradius(pickradius)

Set the pick radius used for containment tests.

Parameters:

pickradius (float) – Pick radius, in points.

Return type:

None

set_rasterized(rasterized)

Force rasterized (bitmap) drawing for vector graphics output.

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

This setting is ignored for pixel-based output.

See also /gallery/misc/rasterization_demo.

Parameters:

rasterized (bool)

Return type:

None

set_segments(segments)[source]
Return type:

None

set_sketch_params(scale=None, length=None, randomness=None)

Set the sketch parameters.

Parameters:
  • scale (float | None) – 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.

  • length (float | None) – The length of the wiggle along the line, in pixels (default 128.0)

  • randomness (float | None) –

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

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

Return type:

None

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:

snap (bool | 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.

Return type:

None

set_transOffset(offset_transform)

Alias for set_offset_transform.

Return type:

None

set_transform(t)

Set the artist transform.

Parameters:

t (Transform | None)

Return type:

None

set_url(url)

Set the url for the artist.

Parameters:

url (str | None)

Return type:

None

set_urls(urls)
Parameters:

urls (Sequence[str | None])

Return type:

None

Notes

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

set_verts(segments)
Return type:

None

set_visible(b)

Set the artist’s visibility.

Parameters:

b (bool)

Return type:

None

set_zorder(level)

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

Parameters:

level (float)

Return type:

None

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

Return a normalized RGBA array corresponding to x.

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

There is one special case, for handling images that are already RGB or RGBA, such as might have been read from an image file. If x is an ~numpy.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 ~numpy.uint8, or it can be floats with values in the 0-1 range; otherwise a ValueError will be raised. Any NaNs or masked elements will be set to 0 alpha. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the preexisting alpha. A ValueError will be raised if the third dimension is other than 3 or 4.

In either case, if bytes is False (default), the RGBA array will be floats in the 0-1 range; if it is True, the returned RGBA array will be ~numpy.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).

Return type:

ndarray

update(props)

[Discouraged] Update this artist’s properties from the dictionary props.

Discouraged

This method exists for historic reasons. Please use .Artist.set instead. artist.update(props) is nowadays almost identical to artist.set(**props) with the only difference that set will additionally check that a property is not specified multiple times through aliases.

Parameters:

props (dict[str, Any]) – Dictionary of properties (keys) and their new values.

Returns:

A list of return values from the configured setters.

Return type:

list[Any]

update_from(other)

Copy properties from other to self.

Return type:

None

update_scalarmappable()

Update colors from the scalar mappable array, if any.

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

Return type:

None

__annotations__ = {}
property axes

The ~.axes.Axes instance the artist resides in, or None.

property cmap
property colorbar

The last colorbar associated with this object. May be None

property colorizer
property figure

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

Setter accepts:

Figure | SubFigure

property mouseover

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

property norm
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 and y sticky edge lists for autoscaling.

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

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

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

Examples

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