• matplotlib.collections、(二)


    参考  matplotlib.collections、(二) - 云+社区 - 腾讯云

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

    Bases: matplotlib.collections.RegularPolyCollection

    Draw a collection of regular asterisks with numsides points.

    numsides

    the number of sides of the polygon

    rotation

    the rotation of the polygon in radians

    sizes

    gives the area of the circle circumscribing the regular polygon in points^2

    Valid Collection keyword arguments:

    offsets and transOffset are used to translate the patch after rendering (default no offsets)

    If any of edgecolors, facecolors, linewidths, antialiaseds are None, they default to their matplotlib.rcParams patch setting, in sequence form.

    Example: see Lasso Demo for a complete example:

    1. offsets = np.random.rand(20,2)
    2. facecolors = [cm.jet(x) for x in np.random.rand(20)]
    3. black = (0,0,0,1)
    4. collection = RegularPolyCollection(
    5. numsides=5, # a pentagon
    6. rotation=0, sizes=(50,),
    7. facecolors=facecolors,
    8. edgecolors=(black,),
    9. linewidths=(1,),
    10. offsets=offsets,
    11. transOffset=ax.transData,
    12. )

    add_callback(self, func)

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

    Parameters:

    func : callable

    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:

    oid : int

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

    See also

    remove_callback

    add_checker(self, checker)

    Add an entry to a dictionary of boolean flags that are set to True when the mappable is changed.

    aname

    autoscale(self)

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

    autoscale_None(self)

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

    axes

    The Axes instance the artist resides in, or None.

    changed(self)

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

    check_update(self, checker)

    If mappable has changed since the last check, return True; else return False

    contains(self, 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(self, 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(self, 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(self, renderer)

    Draw the Artist using the given renderer.

    This method will be overridden in the Artist subclasses. Typically, it is implemented to not have any effect if the Artist is not visible (Artist.get_visible is False).

    Parameters:

    renderer : RendererBase subclass.

    findobj(self, 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_self : bool

    Include self in the list to be checked for a match.

    Returns:

    artists : list of Artist

    format_cursor_data(self, 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_cursor_data

    get_agg_filter(self)

    Return filter function to be used for agg filter.

    get_alpha(self)

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

    get_animated(self)

    Return the animated state.

    get_array(self)

    Return the array

    get_capstyle(self)

    get_children(self)

    Return a list of the child Artists of this Artist.

    get_clim(self)

    return the min, max of the color limits for image scaling

    get_clip_box(self)

    Return the clipbox.

    get_clip_on(self)

    Return whether the artist uses clipping.

    get_clip_path(self)

    Return the clip path.

    get_cmap(self)

    return the colormap

    get_contains(self)

    Return the custom contains function of the artist if set, or None.

    See also

    set_contains

    get_cursor_data(self, 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.

    See also

    format_cursor_data

    get_dashes(self)

    Alias for get_linestyle.

    get_datalim(self, transData)

    get_ec(self)

    Alias for get_edgecolor.

    get_edgecolor(self)

    get_edgecolors(self)

    Alias for get_edgecolor.

    get_facecolor(self)

    get_facecolors(self)

    Alias for get_facecolor.

    get_fc(self)

    Alias for get_facecolor.

    get_figure(self)

    Return the Figure instance the artist belongs to.

    get_fill(self)

    return whether fill is set

    get_gid(self)

    Return the group id.

    get_hatch(self)

    Return the current hatching pattern.

    get_in_layout(self)

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

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

    get_joinstyle(self)

    get_label(self)

    Return the label used for this artist in the legend.

    get_linestyle(self)

    get_linestyles(self)

    Alias for get_linestyle.

    get_linewidth(self)

    get_linewidths(self)

    Alias for get_linewidth.

    get_ls(self)

    Alias for get_linestyle.

    get_lw(self)

    Alias for get_linewidth.

    get_numsides(self)

    get_offset_position(self)

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

    get_offset_transform(self)

    get_offsets(self)

    Return the offsets for the collection.

    get_path_effects(self)

    get_paths(self)

    get_picker(self)

    Return the picking behavior of the artist.

    The possible values are described in set_picker.

    See also

    set_picker, pickable, pick

    get_pickradius(self)

    get_rasterized(self)

    Return whether the artist is to be rasterized.

    get_rotation(self)

    get_sizes(self)

    Returns the sizes of the elements in the collection. The value represents the 'area' of the element.

    Returns:

    sizes : array

    The 'area' of each element.

    get_sketch_params(self)

    Returns the sketch parameters for the artist.

    Returns:

    sketch_params : 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_snap(self)

    Returns the snap setting.

    See set_snap for details.

    get_tightbbox(self, renderer)

    Like Artist.get_window_extent, but includes any clipping.

    Parameters:

    renderer : RendererBase instance

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

    Returns:

    bbox : BBox

    The enclosing bounding box (in figure pixel co-ordinates).

    get_transform(self)

    Return the Transform instance used by this artist.

    get_transformed_clip_path_and_affine(self)

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

    get_transforms(self)

    get_url(self)

    Return the url.

    get_urls(self)

    get_visible(self)

    Return the visibility.

    get_window_extent(self, 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(self)

    Return the artist's zorder.

    have_units(self)

    Return True if units are set on the x or y axes.

    is_transform_set(self)

    Return whether the Artist has an explicitly set transform.

    This is True after set_transform has been called.

    mouseover

    pchanged(self)

    Call all of the registered callbacks.

    This function is triggered internally when a property is changed.

    See also

    add_callback

    remove_callback

    pick(self, 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

    set_picker, get_picker, pickable

    pickable(self)

    Return whether the artist is pickable.

    See also

    set_picker, get_picker, pick

    properties(self)

    Return a dictionary of all the properties of the artist.

    remove(self)

    Remove the artist from the figure if possible.

    The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

    Note: relim will not see collections even if the collection was added to the axes with autolim = True.

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

    remove_callback(self, oid)

    Remove a callback based on its observer id.

    See also

    add_callback

    set(self, **kwargs)

    A property batch setter. Pass kwargs to set properties.

    set_aa(self, aa)

    Alias for set_antialiased.

    set_agg_filter(self, filter_func)

    Set the agg filter.

    Parameters:

    filter_func : callable

    A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

    set_alpha(self, alpha)

    Set the alpha transparencies of the collection.

    Parameters:

    alpha : float or None

    set_animated(self, b)

    Set the artist's animation state.

    Parameters:

    b : bool

    set_antialiased(self, aa)

    Set the antialiasing state for rendering.

    Parameters:

    aa : bool or sequence of bools

    set_antialiaseds(self, aa)

    Alias for set_antialiased.

    set_array(self, A)

    Set the image array from numpy array A.

    Parameters:

    A : ndarray

    set_capstyle(self, cs)

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

    Parameters:

    cs : {'butt', 'round', 'projecting'}

    The capstyle

    set_clim(self, vmin=None, vmax=None)

    set the norm limits for image scaling; if vmin is a length2 sequence, interpret it as (vmin, vmax) which is used to support setp

    ACCEPTS: a length 2 sequence of floats; may be overridden in methods that have vmin and vmax kwargs.

    set_clip_box(self, clipbox)

    Set the artist's clip Bbox.

    Parameters:

    clipbox : Bbox

    set_clip_on(self, b)

    Set whether the artist uses clipping.

    When False artists will be visible out side of the axes which can lead to unexpected results.

    Parameters:

    b : bool

    set_clip_path(self, path, transform=None)

    Set the artist's clip path, which may be:

    • a Patch (or subclass) instance; or
    • a Path instance, in which case a Transform instance, which will be applied to the path before using it for clipping, must be provided; or
    • None, to remove a previously set clipping path.

    For efficiency, if the path happens to be an axis-aligned rectangle, this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

    ACCEPTS: [(Path, Transform) | Patch | None]

    set_cmap(self, cmap)

    set the colormap for luminance data

    Parameters:

    cmap : colormap or registered colormap name

    set_color(self, c)

    Set both the edgecolor and the facecolor.

    Parameters:

    c : color or sequence of rgba tuples

    See also

    Collection.set_facecolor, Collection.set_edgecolor

    For setting the edge or face color individually.

    set_contains(self, picker)

    Define a custom contains test for the artist.

    The provided callable replaces the default contains method of the artist.

    Parameters:

    picker : callable

    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.

    set_dashes(self, ls)

    Alias for set_linestyle.

    set_ec(self, c)

    Alias for set_edgecolor.

    set_edgecolor(self, c)

    Set the edgecolor(s) of the collection.

    Parameters:

    c : color or sequence of colors or 'face'

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

    set_edgecolors(self, c)

    Alias for set_edgecolor.

    set_facecolor(self, c)

    Set the facecolor(s) of the collection. c can be a matplotlib color spec (all patches have same color), or a sequence of specs; if it is a sequence the patches will cycle through the sequence.

    If c is 'none', the patch will not be filled.

    Parameters:

    c : color or sequence of colors

    set_facecolors(self, c)

    Alias for set_facecolor.

    set_fc(self, c)

    Alias for set_facecolor.

    set_figure(self, fig)

    Set the Figure instance the artist belongs to.

    Parameters:

    fig : Figure

    set_gid(self, gid)

    Set the (group) id for the artist.

    Parameters:

    gid : str

    set_hatch(self, hatch)

    Set the hatching pattern

    hatch can be one of:

    1. / - diagonal hatching
    2. \ - back diagonal
    3. | - vertical
    4. - - horizontal
    5. + - crossed
    6. x - crossed diagonal
    7. o - small circle
    8. O - large circle
    9. . - dots
    10. * - 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(self, in_layout)

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

    Parameters:

    in_layout : bool

    set_joinstyle(self, js)

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

    Parameters:

    js : {'miter', 'round', 'bevel'}

    The joinstyle

    set_label(self, s)

    Set a label that will be displayed in the legend.

    Parameters:

    s : object

    s will be converted to a string by calling str.

    set_linestyle(self, ls)

    Set the linestyle(s) for the collection.

    linestyledescription
    '-' 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:

    ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}

    The line style.

    set_linestyles(self, ls)

    Alias for set_linestyle.

    set_linewidth(self, 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 or sequence of floats

    set_linewidths(self, lw)

    Alias for set_linewidth.

    set_ls(self, ls)

    Alias for set_linestyle.

    set_lw(self, lw)

    Alias for set_linewidth.

    set_norm(self, norm)

    Set the normalization instance.

    Parameters:

    norm : Normalize

    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_position(self, offset_position)

    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'}

    set_offsets(self, offsets)

    Set the offsets for the collection.

    Parameters:

    offsets : float or sequence of floats

    set_path_effects(self, path_effects)

    Set the path effects.

    Parameters:

    path_effects : AbstractPathEffect

    set_paths(self)

    set_picker(self, picker)

    Define the picking behavior of the artist.

    Parameters:

    picker : None or bool or float 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 float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if it's data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event

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

      hit, props = picker(artist, mouseevent)

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

    set_pickradius(self, pr)

    Set the pick radius used for containment tests.

    Parameters:

    d : float

    Pick radius, in points.

    set_rasterized(self, rasterized)

    Force rasterized (bitmap) drawing in vector backend output.

    Defaults to None, which implies the backend's default behavior.

    Parameters:

    rasterized : bool or None

    set_sizes(self, sizes, dpi=72.0)

    Set the sizes of each member of the collection.

    Parameters:

    sizes : ndarray or None

    The size to set for each element of the collection. The value is the 'area' of the element.

    dpi : float

    The dpi of the canvas. Defaults to 72.0.

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

    Sets the sketch parameters.

    Parameters:

    scale : float, 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.

    length : float, optional

    The length of the wiggle along the line, in pixels (default 128.0)

    randomness : float, optional

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

    set_snap(self, 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 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_transform(self, t)

    Set the artist transform.

    Parameters:

    t : Transform

    set_url(self, url)

    Set the url for the artist.

    Parameters:

    url : str

    set_urls(self, urls)

    Parameters:

    urls : List[str] or None

    set_visible(self, b)

    Set the artist's visibility.

    Parameters:

    b : bool

    set_zorder(self, level)

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

    Parameters:

    level : float

    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.

    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 and y lists can be modified in place as needed.

    Examples

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

    to_rgba(self, 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(self, props)

    Update this artist's properties from the dictionary props.

    update_from(self, other)

    copy properties from other to self

    update_scalarmappable(self)

    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.

    xranges

    sequence of (xmin, xwidth)

    yrange

    ymin, ywidth

    Valid Collection keyword arguments:

    offsets and transOffset are used to translate the patch after rendering (default no offsets)

    If any of edgecolors, facecolors, linewidths, antialiaseds are None, they default to their matplotlib.rcParams patch setting, in sequence form.

    add_callback(self, func)

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

    Parameters:

    func : callable

    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:

    oid : int

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

    See also

    remove_callback

    add_checker(self, checker)

    Add an entry to a dictionary of boolean flags that are set to True when the mappable is changed.

    aname

    autoscale(self)

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

    autoscale_None(self)

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

    axes

    The Axes instance the artist resides in, or None.

    changed(self)

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

    check_update(self, checker)

    If mappable has changed since the last check, return True; else return False

    contains(self, 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(self, 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(self, 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(self, renderer)

    Draw the Artist using the given renderer.

    This method will be overridden in the Artist subclasses. Typically, it is implemented to not have any effect if the Artist is not visible (Artist.get_visible is False).

    Parameters:

    renderer : RendererBase subclass.

    findobj(self, 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_self : bool

    Include self in the list to be checked for a match.

    Returns:

    artists : list of Artist

    format_cursor_data(self, 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_cursor_data

    get_agg_filter(self)

    Return filter function to be used for agg filter.

    get_alpha(self)

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

    get_animated(self)

    Return the animated state.

    get_array(self)

    Return the array

    get_capstyle(self)

    get_children(self)

    Return a list of the child Artists of this Artist.

    get_clim(self)

    return the min, max of the color limits for image scaling

    get_clip_box(self)

    Return the clipbox.

    get_clip_on(self)

    Return whether the artist uses clipping.

    get_clip_path(self)

    Return the clip path.

    get_cmap(self)

    return the colormap

    get_contains(self)

    Return the custom contains function of the artist if set, or None.

    See also

    set_contains

    get_cursor_data(self, 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.

    See also

    format_cursor_data

    get_dashes(self)

    Alias for get_linestyle.

    get_datalim(self, transData)

    get_ec(self)

    Alias for get_edgecolor.

    get_edgecolor(self)

    get_edgecolors(self)

    Alias for get_edgecolor.

    get_facecolor(self)

    get_facecolors(self)

    Alias for get_facecolor.

    get_fc(self)

    Alias for get_facecolor.

    get_figure(self)

    Return the Figure instance the artist belongs to.

    get_fill(self)

    return whether fill is set

    get_gid(self)

    Return the group id.

    get_hatch(self)

    Return the current hatching pattern.

    get_in_layout(self)

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

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

    get_joinstyle(self)

    get_label(self)

    Return the label used for this artist in the legend.

    get_linestyle(self)

    get_linestyles(self)

    Alias for get_linestyle.

    get_linewidth(self)

    get_linewidths(self)

    Alias for get_linewidth.

    get_ls(self)

    Alias for get_linestyle.

    get_lw(self)

    Alias for get_linewidth.

    get_offset_position(self)

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

    get_offset_transform(self)

    get_offsets(self)

    Return the offsets for the collection.

    get_path_effects(self)

    get_paths(self)

    get_picker(self)

    Return the picking behavior of the artist.

    The possible values are described in set_picker.

    See also

    set_picker, pickable, pick

    get_pickradius(self)

    get_rasterized(self)

    Return whether the artist is to be rasterized.

    get_sizes(self)

    Returns the sizes of the elements in the collection. The value represents the 'area' of the element.

    Returns:

    sizes : array

    The 'area' of each element.

    get_sketch_params(self)

    Returns the sketch parameters for the artist.

    Returns:

    sketch_params : 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_snap(self)

    Returns the snap setting.

    See set_snap for details.

    get_tightbbox(self, renderer)

    Like Artist.get_window_extent, but includes any clipping.

    Parameters:

    renderer : RendererBase instance

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

    Returns:

    bbox : BBox

    The enclosing bounding box (in figure pixel co-ordinates).

    get_transform(self)

    Return the Transform instance used by this artist.

    get_transformed_clip_path_and_affine(self)

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

    get_transforms(self)

    get_url(self)

    Return the url.

    get_urls(self)

    get_visible(self)

    Return the visibility.

    get_window_extent(self, 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(self)

    Return the artist's zorder.

    have_units(self)

    Return True if units are set on the x or y axes.

    is_transform_set(self)

    Return whether the Artist has an explicitly set transform.

    This is True after set_transform has been called.

    mouseover

    pchanged(self)

    Call all of the registered callbacks.

    This function is triggered internally when a property is changed.

    See also

    add_callback

    remove_callback

    pick(self, 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

    set_picker, get_picker, pickable

    pickable(self)

    Return whether the artist is pickable.

    See also

    set_picker, get_picker, pick

    properties(self)

    Return a dictionary of all the properties of the artist.

    remove(self)

    Remove the artist from the figure if possible.

    The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.

    Note: relim will not see collections even if the collection was added to the axes with autolim = True.

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

    remove_callback(self, oid)

    Remove a callback based on its observer id.

    See also

    add_callback

    set(self, **kwargs)

    A property batch setter. Pass kwargs to set properties.

    set_aa(self, aa)

    Alias for set_antialiased.

    set_agg_filter(self, filter_func)

    Set the agg filter.

    Parameters:

    filter_func : callable

    A filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array.

    set_alpha(self, alpha)

    Set the alpha transparencies of the collection.

    Parameters:

    alpha : float or None

    set_animated(self, b)

    Set the artist's animation state.

    Parameters:

    b : bool

    set_antialiased(self, aa)

    Set the antialiasing state for rendering.

    Parameters:

    aa : bool or sequence of bools

    set_antialiaseds(self, aa)

    Alias for set_antialiased.

    set_array(self, A)

    Set the image array from numpy array A.

    Parameters:

    A : ndarray

    set_capstyle(self, cs)

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

    Parameters:

    cs : {'butt', 'round', 'projecting'}

    The capstyle

    set_clim(self, vmin=None, vmax=None)

    set the norm limits for image scaling; if vmin is a length2 sequence, interpret it as (vmin, vmax) which is used to support setp

    ACCEPTS: a length 2 sequence of floats; may be overridden in methods that have vmin and vmax kwargs.

    set_clip_box(self, clipbox)

    Set the artist's clip Bbox.

    Parameters:

    clipbox : Bbox

    set_clip_on(self, b)

    Set whether the artist uses clipping.

    When False artists will be visible out side of the axes which can lead to unexpected results.

    Parameters:

    b : bool

    set_clip_path(self, path, transform=None)

    Set the artist's clip path, which may be:

    • a Patch (or subclass) instance; or
    • a Path instance, in which case a Transform instance, which will be applied to the path before using it for clipping, must be provided; or
    • None, to remove a previously set clipping path.

    For efficiency, if the path happens to be an axis-aligned rectangle, this method will set the clipping box to the corresponding rectangle and set the clipping path to None.

    ACCEPTS: [(Path, Transform) | Patch | None]

    set_cmap(self, cmap)

    set the colormap for luminance data

    Parameters:

    cmap : colormap or registered colormap name

    set_color(self, c)

    Set both the edgecolor and the facecolor.

    Parameters:

    c : color or sequence of rgba tuples

    See also

    Collection.set_facecolor, Collection.set_edgecolor

    For setting the edge or face color individually.

    set_contains(self, picker)

    Define a custom contains test for the artist.

    The provided callable replaces the default contains method of the artist.

    Parameters:

    picker : callable

    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.

    set_dashes(self, ls)

    Alias for set_linestyle.

    set_ec(self, c)

    Alias for set_edgecolor.

    set_edgecolor(self, c)

    Set the edgecolor(s) of the collection.

    Parameters:

    c : color or sequence of colors or 'face'

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

    set_edgecolors(self, c)

    Alias for set_edgecolor.

    set_facecolor(self, c)

    Set the facecolor(s) of the collection. c can be a matplotlib color spec (all patches have same color), or a sequence of specs; if it is a sequence the patches will cycle through the sequence.

    If c is 'none', the patch will not be filled.

    Parameters:

    c : color or sequence of colors

    set_facecolors(self, c)

    Alias for set_facecolor.

    set_fc(self, c)

    Alias for set_facecolor.

    set_figure(self, fig)

    Set the Figure instance the artist belongs to.

    Parameters:

    fig : Figure

    set_gid(self, gid)

    Set the (group) id for the artist.

    Parameters:

    gid : str

    set_hatch(self, hatch)

    Set the hatching pattern

    hatch can be one of:

    1. / - diagonal hatching
    2. \ - back diagonal
    3. | - vertical
    4. - - horizontal
    5. + - crossed
    6. x - crossed diagonal
    7. o - small circle
    8. O - large circle
    9. . - dots
    10. * - 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(self, in_layout)

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

    Parameters:

    in_layout : bool

    set_joinstyle(self, js)

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

    Parameters:

    js : {'miter', 'round', 'bevel'}

    The joinstyle

    set_label(self, s)

    Set a label that will be displayed in the legend.

    Parameters:

    s : object

    s will be converted to a string by calling str.

    set_linestyle(self, ls)

    Set the linestyle(s) for the collection.

    linestyledescription
    '-' 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:

    ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}

    The line style.

    set_linestyles(self, ls)

    Alias for set_linestyle.

    set_linewidth(self, 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 or sequence of floats

    set_linewidths(self, lw)

    Alias for set_linewidth.

    set_ls(self, ls)

    Alias for set_linestyle.

    set_lw(self, lw)

    Alias for set_linewidth.

    set_norm(self, norm)

    Set the normalization instance.

    Parameters:

    norm : Normalize

    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_position(self, offset_position)

    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'}

    set_offsets(self, offsets)

    Set the offsets for the collection.

    Parameters:

    offsets : float or sequence of floats

    set_path_effects(self, path_effects)

    Set the path effects.

    Parameters:

    path_effects : AbstractPathEffect

    set_paths(self, verts, closed=True)

    This allows one to delay initialization of the vertices.

    set_picker(self, picker)

    Define the picking behavior of the artist.

    Parameters:

    picker : None or bool or float 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 float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if it's data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event

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

      hit, props = picker(artist, mouseevent)
      

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

    set_pickradius(self, pr)

    Set the pick radius used for containment tests.

    Parameters:

    d : float

    Pick radius, in points.

    set_rasterized(self, rasterized)

    Force rasterized (bitmap) drawing in vector backend output.

    Defaults to None, which implies the backend's default behavior.

    Parameters:

    rasterized : bool or None

    set_sizes(self, sizes, dpi=72.0)

    Set the sizes of each member of the collection.

    Parameters:

    sizes : ndarray or None

    The size to set for each element of the collection. The value is the 'area' of the element.

    dpi : float

    The dpi of the canvas. Defaults to 72.0.

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

    Sets the sketch parameters.

    Parameters:

    scale : float, 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.

    length : float, optional

    The length of the wiggle along the line, in pixels (default 128.0)

    randomness : float, optional

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

    set_snap(self, 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 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_transform(self, t)

    Set the artist transform.

    Parameters:

    t : Transform

    set_url(self, url)

    Set the url for the artist.

    Parameters:

    url : str

    set_urls(self, urls)

    Parameters:

    urls : List[str] or None

    set_verts(self, verts, closed=True)

    This allows one to delay initialization of the vertices.

    set_verts_and_codes(self, verts, codes)

    This allows one to initialize vertices with path codes.

    set_visible(self, b)

    Set the artist's visibility.

    Parameters:

    b : bool

    set_zorder(self, level)

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

    Parameters:

    level : float

    static span_where(x, ymin, ymax, where, **kwargs)[source]

    Create a BrokenBarHCollection to plot horizontal bars from over the regions in x where where is True. The bars range on the y-axis from ymin to ymax

    A BrokenBarHCollection is returned. kwargs are passed on to the collection.

    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.

    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 and y lists can be modified in place as needed.

    Examples

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

    to_rgba(self, 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(self, props)

    Update this artist's properties from the dictionary props.

    update_from(self, other)

    copy properties from other to self

    update_scalarmappable(self)

    Update colors from the scalar mappable array, if it is not None.

    zorder = 0

  • 相关阅读:
    基于AMD EPYC服务器的EDA芯片设计解决方案
    【深蓝学院】手写VIO第7章--VINS初始化和VIO系统--作业
    ZBrush软件这些实用小技巧,你知道几个?
    2022 年杭电多校第十场补题记录
    每个人都应该去学写作
    【flask扩展】使用Flask-Mail发送邮件
    细胞膜包裹精氨酸脱亚胺酶脂质纳米粒/融合细胞膜包裹尿酸酶/过氧化氢酶脂质纳米粒的研究
    树和二叉树
    CentOS7用nmcli和nmtui配置网络IP地址,默认是生成network的配置文件,在network-scripts文件夹下
    JVM高频面试题
  • 原文地址:https://blog.csdn.net/weixin_36670529/article/details/101347881