smpl.plot.Line2D¶
- class smpl.plot.Line2D(xdata, ydata, *, linewidth=None, linestyle=None, color=None, gapcolor=None, marker=None, markersize=None, markeredgewidth=None, markeredgecolor=None, markerfacecolor=None, markerfacecoloralt='none', fillstyle=None, antialiased=None, dash_capstyle=None, solid_capstyle=None, dash_joinstyle=None, solid_joinstyle=None, pickradius=5, drawstyle=None, markevery=None, **kwargs)[source]¶
Bases:
ArtistA line - the line can have both a solid linestyle connecting all the vertices, and a marker at each vertex. Additionally, the drawing of the solid line is influenced by the drawstyle, e.g., one can create “stepped” lines in various styles.
- __init__(xdata, ydata, *, linewidth=None, linestyle=None, color=None, gapcolor=None, marker=None, markersize=None, markeredgewidth=None, markeredgecolor=None, markerfacecolor=None, markerfacecoloralt='none', fillstyle=None, antialiased=None, dash_capstyle=None, solid_capstyle=None, dash_joinstyle=None, solid_joinstyle=None, pickradius=5, drawstyle=None, markevery=None, **kwargs)[source]¶
Create a .Line2D instance with x and y data in sequences of xdata, ydata.
Additional keyword arguments are .Line2D properties:
- 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: scalar or None animated: bool antialiased or aa: bool clip_box: .Bbox clip_on: bool clip_path: Patch or (Path, Transform) or None color or c: color dash_capstyle: .CapStyle or {‘butt’, ‘projecting’, ‘round’} dash_joinstyle: .JoinStyle or {‘miter’, ‘round’, ‘bevel’} dashes: sequence of floats (on/off ink in points) or (None, None) data: (2, N) array or two 1D arrays drawstyle or ds: {‘default’, ‘steps’, ‘steps-pre’, ‘steps-mid’, ‘steps-post’}, default: ‘default’ figure: .Figure fillstyle: {‘full’, ‘left’, ‘right’, ‘bottom’, ‘top’, ‘none’} gapcolor: color or None gid: str in_layout: bool label: object linestyle or ls: {‘-’, ‘–’, ‘-.’, ‘:’, ‘’, (offset, on-off-seq), …} linewidth or lw: float marker: marker style string, ~.path.Path or ~.markers.MarkerStyle markeredgecolor or mec: color markeredgewidth or mew: float markerfacecolor or mfc: color markerfacecoloralt or mfcalt: color markersize or ms: float markevery: None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool] mouseover: bool path_effects: .AbstractPathEffect picker: float or callable[[Artist, Event], tuple[bool, dict]] pickradius: unknown rasterized: bool sketch_params: (scale: float, length: float, randomness: float) snap: bool or None solid_capstyle: .CapStyle or {‘butt’, ‘projecting’, ‘round’} solid_joinstyle: .JoinStyle or {‘miter’, ‘round’, ‘bevel’} transform: unknown url: str visible: bool xdata: 1D array ydata: 1D array zorder: float
See
set_linestyle()for a description of the line styles,set_marker()for a description of the markers, andset_drawstyle()for a description of the draw styles.
Methods
__init__(xdata, ydata, *[, linewidth, ...])Create a .Line2D instance with x and y data in sequences of xdata, ydata.
add_callback(func)Add a callback function that will be called whenever one of the .Artist's properties changes.
contains(mouseevent)Test whether mouseevent occurred on the line.
Convert x using the unit type of the xaxis.
Convert y using the unit type of the yaxis.
draw(renderer)Draw the Artist (and its children) using the given renderer.
findobj([match, include_self])Find artist objects.
format_cursor_data(data)Return a string representation of data.
get_aa()Alias for get_antialiased.
Return filter function to be used for agg filter.
Return the alpha value used for blending - not supported on all backends.
Return whether the artist is animated.
Return whether antialiased rendering is used.
get_bbox()Get the bounding box of this line.
get_c()Alias for get_color.
Return a list of the child .Artists of this .Artist.
Return the clipbox.
Return whether the artist uses clipping.
Return the clip path.
Return the line color.
get_cursor_data(event)Return the cursor data for a given event.
Return the .CapStyle for dashed lines.
Return the .JoinStyle for dashed lines.
get_data([orig])Return the line data as an
(xdata, ydata)pair.Return the drawstyle.
get_ds()Alias for get_drawstyle.
Return the .Figure instance the artist belongs to.
Return the marker fill style.
Return the line gapcolor.
get_gid()Return the group id.
Return boolean flag,
Trueif artist is included in layout calculations.Return the label used for this artist in the legend.
Return the linestyle.
Return the linewidth in points.
get_ls()Alias for get_linestyle.
get_lw()Alias for get_linewidth.
Return the line marker.
Return the marker edge color.
Return the marker edge width in points.
Return the marker face color.
Return the alternate marker face color.
Return the marker size in points.
Return the markevery setting for marker subsampling.
get_mec()Alias for get_markeredgecolor.
get_mew()Alias for get_markeredgewidth.
get_mfc()Alias for get_markerfacecolor.
Alias for get_markerfacecoloralt.
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
get_ms()Alias for get_markersize.
get_path()Return the ~matplotlib.path.Path associated with this line.
get_path_effects()Return the picking behavior of the artist.
Return the pick radius used for containment tests.
Return whether the artist is to be rasterized.
Return the sketch parameters for the artist.
get_snap()Return the snap setting.
Return the .CapStyle for solid lines.
Return the .JoinStyle for solid lines.
get_tightbbox([renderer])Like .Artist.get_window_extent, but includes any clipping.
Return the .Transform instance used by this artist.
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
get_url()Return the url.
Return the visibility.
get_window_extent([renderer])Get the artist's bounding box in display space.
get_xdata([orig])Return the xdata.
Return the xy data as a Nx2 numpy array.
get_ydata([orig])Return the ydata.
Return the artist's zorder.
Return whether units are set on any axis.
Return whether line has a dashed linestyle.
Return whether the Artist has an explicitly set transform.
pchanged()Call all of the registered callbacks.
pick(mouseevent)Process a pick event.
pickable()Return whether the artist is pickable.
Return a dictionary of all the properties of the artist.
recache([always])recache_always()remove()Remove the artist from the figure if possible.
remove_callback(oid)Remove a callback based on its observer id.
set(*[, agg_filter, alpha, animated, ...])Set multiple properties at once.
set_aa(b)Alias for set_antialiased.
set_agg_filter(filter_func)Set the agg filter.
set_alpha(alpha)Set the alpha value used for blending - not supported on all backends.
set_animated(b)Set whether the artist is intended to be used in an animation.
Set whether to use antialiased rendering.
set_c(color)Alias for set_color.
set_clip_box(clipbox)Set the artist's clip .Bbox.
set_clip_on(b)Set whether the artist uses clipping.
set_clip_path(path[, transform])Set the artist's clip path.
set_color(color)Set the color of the line.
How to draw the end caps if the line is ~Line2D.is_dashed.
How to join segments of the line if it ~Line2D.is_dashed.
set_dashes(seq)Set the dash sequence.
set_data(*args)Set the x and y data.
set_drawstyle(drawstyle)Set the drawstyle of the plot.
set_ds(drawstyle)Alias for set_drawstyle.
set_figure(fig)Set the .Figure instance the artist belongs to.
set_fillstyle(fs)Set the marker fill style.
set_gapcolor(gapcolor)Set a color to fill the gaps in the dashed line style.
set_gid(gid)Set the (group) id for the artist.
set_in_layout(in_layout)Set if artist is to be included in layout calculations, E.g.
set_label(s)Set a label that will be displayed in the legend.
set_linestyle(ls)Set the linestyle of the line.
Set the line width in points.
set_ls(ls)Alias for set_linestyle.
set_lw(w)Alias for set_linewidth.
set_marker(marker)Set the line marker.
Set the marker edge color.
Set the marker edge width in points.
Set the marker face color.
Set the alternate marker face color.
set_markersize(sz)Set the marker size in points.
set_markevery(every)Set the markevery property to subsample the plot when using markers.
set_mec(ec)Alias for set_markeredgecolor.
set_mew(ew)Alias for set_markeredgewidth.
set_mfc(fc)Alias for set_markerfacecolor.
set_mfcalt(fc)Alias for set_markerfacecoloralt.
set_mouseover(mouseover)Set whether this artist is queried for custom context information when the mouse cursor moves over it.
set_ms(sz)Alias for set_markersize.
set_path_effects(path_effects)Set the path effects.
set_picker(p)Set the event picker details for the line.
set_pickradius(pickradius)Set the pick radius used for containment tests.
set_rasterized(rasterized)Force rasterized (bitmap) drawing for vector graphics output.
set_sketch_params([scale, length, randomness])Set the sketch parameters.
set_snap(snap)Set the snapping behavior.
How to draw the end caps if the line is solid (not ~Line2D.is_dashed)
How to join segments if the line is solid (not ~Line2D.is_dashed).
Set the artist transform.
set_url(url)Set the url for the artist.
set_visible(b)Set the artist's visibility.
set_xdata(x)Set the data array for x.
set_ydata(y)Set the data array for y.
set_zorder(level)Set the zorder for the artist.
update(props)Update this artist's properties from the dict props.
update_from(other)Copy properties from other to self.
Attributes
The ~.axes.Axes instance the artist resides in, or None.
drawStyleKeysdrawStylesfillStylesfilled_markerslineStylesmarkersReturn whether this artist is queried for custom context information when the mouse cursor moves over it.
Return the pick radius used for containment tests.
Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.
xandysticky edge lists for autoscaling.zorder- add_callback(func)¶
Add a callback function that will be called whenever one of the .Artist’s properties changes.
Parameters¶
- funccallable
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling .Artist. Return values may exist but are ignored.
Returns¶
- int
The observer id associated with the callback. This id can be used for removing the callback with .remove_callback later.
See Also¶
remove_callback
- property axes¶
The ~.axes.Axes instance the artist resides in, or None.
- contains(mouseevent)[source]¶
Test whether mouseevent occurred on the line.
An event is deemed to have occurred “on” the line if it is less than
self.pickradius(default: 5 points) away from it. Use ~.Line2D.get_pickradius or ~.Line2D.set_pickradius to get or set the pick radius.Parameters¶
mouseevent : matplotlib.backend_bases.MouseEvent
Returns¶
- containsbool
Whether any values are within the radius.
- detailsdict
A dictionary
{'ind': pointlist}, where pointlist is a list of points of the line that are within the pickradius around the event position.TODO: sort returned indices by distance
- 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)[source]¶
Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (.Artist.get_visible returns False).
Parameters¶
renderer : .RendererBase subclass.
Notes¶
This method is overridden in the Artist subclasses.
- findobj(match=None, include_self=True)¶
Find artist objects.
Recursively find all .Artist instances contained in the artist.
Parameters¶
- match
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True.A class instance: e.g., .Line2D. The result will only contain artists of this class or its subclasses (
isinstancecheck).
- include_selfbool
Include self in the list to be checked for a match.
Returns¶
list of .Artist
- format_cursor_data(data)¶
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar’s formatter.
See Also¶
get_cursor_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_c()¶
Alias for get_color.
- get_children()¶
Return a list of the child .Artists of this .Artist.
- get_clip_box()¶
Return the clipbox.
- get_clip_on()¶
Return whether the artist uses clipping.
- get_clip_path()¶
Return the clip path.
- 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 : matplotlib.backend_bases.MouseEvent
See Also¶
format_cursor_data
- get_dash_capstyle()[source]¶
Return the .CapStyle for dashed lines.
See also ~.Line2D.set_dash_capstyle.
- get_dash_joinstyle()[source]¶
Return the .JoinStyle for dashed lines.
See also ~.Line2D.set_dash_joinstyle.
- get_data(orig=True)[source]¶
Return the line data as an
(xdata, ydata)pair.If orig is True, return the original data.
- get_ds()¶
Alias for get_drawstyle.
- get_figure()¶
Return the .Figure instance the artist belongs to.
- get_gid()¶
Return the group id.
- get_in_layout()¶
Return boolean flag,
Trueif artist is included in layout calculations.E.g. /tutorials/intermediate/constrainedlayout_guide, .Figure.tight_layout(), and
fig.savefig(fname, bbox_inches='tight').
- get_label()¶
Return the label used for this artist in the legend.
- get_ls()¶
Alias for get_linestyle.
- get_lw()¶
Alias for get_linewidth.
- get_markeredgewidth()[source]¶
Return the marker edge width in points.
See also ~.Line2D.set_markeredgewidth.
- get_markerfacecoloralt()[source]¶
Return the alternate marker face color.
See also ~.Line2D.set_markerfacecoloralt.
- get_markevery()[source]¶
Return the markevery setting for marker subsampling.
See also ~.Line2D.set_markevery.
- get_mec()¶
Alias for get_markeredgecolor.
- get_mew()¶
Alias for get_markeredgewidth.
- get_mfc()¶
Alias for get_markerfacecolor.
- get_mfcalt()¶
Alias for get_markerfacecoloralt.
- get_mouseover()¶
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
- get_ms()¶
Alias for get_markersize.
- get_picker()¶
Return the picking behavior of the artist.
The possible values are described in .set_picker.
See Also¶
set_picker, pickable, pick
- get_pickradius()[source]¶
Return the pick radius used for containment tests.
See .contains for more details.
- get_rasterized()¶
Return whether the artist is to be rasterized.
- get_sketch_params()¶
Return the sketch parameters for the artist.
Returns¶
tuple or None
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
- get_snap()¶
Return the snap setting.
See .set_snap for details.
- get_solid_capstyle()[source]¶
Return the .CapStyle for solid lines.
See also ~.Line2D.set_solid_capstyle.
- get_solid_joinstyle()[source]¶
Return the .JoinStyle for solid lines.
See also ~.Line2D.set_solid_joinstyle.
- get_tightbbox(renderer=None)¶
Like .Artist.get_window_extent, but includes any clipping.
Parameters¶
- renderer.RendererBase subclass
renderer that will be used to draw the figures (i.e.
fig.canvas.get_renderer())
Returns¶
- .Bbox
The enclosing bounding box (in figure pixel coordinates).
- 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_url()¶
Return the url.
- get_visible()¶
Return the visibility.
- get_window_extent(renderer=None)[source]¶
Get the artist’s 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_xdata(orig=True)[source]¶
Return the xdata.
If orig is True, return the original data, else the processed data.
- get_ydata(orig=True)[source]¶
Return the ydata.
If orig is True, return the original data, else the processed data.
- get_zorder()¶
Return the artist’s zorder.
- have_units()¶
Return whether units are set on any axis.
- is_dashed()[source]¶
Return whether line has a dashed linestyle.
A custom linestyle is assumed to be dashed, we do not inspect the
onoffseqdirectly.See also ~.Line2D.set_linestyle.
- is_transform_set()¶
Return whether the Artist has an explicitly set transform.
This is True after .set_transform has been called.
- property mouseover¶
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
- pchanged()¶
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See Also¶
add_callback remove_callback
- 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¶
set_picker, get_picker, pickable
- property pickradius¶
Return the pick radius used for containment tests.
See .contains for more details.
- properties()¶
Return a dictionary of all the properties of the artist.
- remove()¶
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with .FigureCanvasBase.draw_idle. Call ~.axes.Axes.relim to update the axes limits if desired.
Note: ~.axes.Axes.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.
- set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, dash_capstyle=<UNSET>, dash_joinstyle=<UNSET>, dashes=<UNSET>, data=<UNSET>, drawstyle=<UNSET>, fillstyle=<UNSET>, gapcolor=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, marker=<UNSET>, markeredgecolor=<UNSET>, markeredgewidth=<UNSET>, markerfacecolor=<UNSET>, markerfacecoloralt=<UNSET>, markersize=<UNSET>, markevery=<UNSET>, mouseover=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, solid_capstyle=<UNSET>, solid_joinstyle=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, xdata=<UNSET>, ydata=<UNSET>, zorder=<UNSET>)¶
Set multiple properties at once.
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: scalar or None animated: bool antialiased: bool clip_box: .Bbox clip_on: bool clip_path: Patch or (Path, Transform) or None color: color dash_capstyle: .CapStyle or {‘butt’, ‘projecting’, ‘round’} dash_joinstyle: .JoinStyle or {‘miter’, ‘round’, ‘bevel’} dashes: sequence of floats (on/off ink in points) or (None, None) data: (2, N) array or two 1D arrays drawstyle: {‘default’, ‘steps’, ‘steps-pre’, ‘steps-mid’, ‘steps-post’}, default: ‘default’ figure: .Figure fillstyle: {‘full’, ‘left’, ‘right’, ‘bottom’, ‘top’, ‘none’} gapcolor: color or None gid: str in_layout: bool label: object linestyle: {‘-’, ‘–’, ‘-.’, ‘:’, ‘’, (offset, on-off-seq), …} linewidth: float marker: marker style string, ~.path.Path or ~.markers.MarkerStyle markeredgecolor: color markeredgewidth: float markerfacecolor: color markerfacecoloralt: color markersize: float markevery: None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool] mouseover: bool path_effects: .AbstractPathEffect picker: float or callable[[Artist, Event], tuple[bool, dict]] pickradius: unknown rasterized: bool sketch_params: (scale: float, length: float, randomness: float) snap: bool or None solid_capstyle: .CapStyle or {‘butt’, ‘projecting’, ‘round’} solid_joinstyle: .JoinStyle or {‘miter’, ‘round’, ‘bevel’} transform: unknown url: str visible: bool xdata: 1D array ydata: 1D array zorder: float
- set_aa(b)¶
Alias for set_antialiased.
- set_agg_filter(filter_func)¶
Set the agg filter.
Parameters¶
- filter_funccallable
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
- set_alpha(alpha)¶
Set the alpha value used for blending - not supported on all backends.
Parameters¶
- alphascalar or None
alpha must be within the 0-1 range, inclusive.
- 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 /tutorials/advanced/blitting.
Parameters¶
b : bool
- set_c(color)¶
Alias for set_color.
- set_clip_on(b)¶
Set whether the artist uses clipping.
When False artists will be visible outside of the Axes which can lead to unexpected results.
Parameters¶
b : bool
- set_clip_path(path, transform=None)¶
Set the artist’s clip path.
Parameters¶
- path.Patch or .Path or .TransformedPath or None
The clip path. If given a .Path, transform must be provided as well. If None, a previously set clip path is removed.
- transform~matplotlib.transforms.Transform, optional
Only used if path is a .Path, in which case the given .Path is converted to a .TransformedPath using transform.
Notes¶
For efficiency, if path is a .Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to
None.For technical reasons (support of ~.Artist.set), a tuple (path, transform) is also accepted as a single positional parameter.
- set_dash_capstyle(s)[source]¶
How to draw the end caps if the line is ~Line2D.is_dashed.
The default capstyle is :rc:`lines.dash_capstyle`.
Parameters¶
s : .CapStyle or {‘butt’, ‘projecting’, ‘round’}
- set_dash_joinstyle(s)[source]¶
How to join segments of the line if it ~Line2D.is_dashed.
The default joinstyle is :rc:`lines.dash_joinstyle`.
Parameters¶
s : .JoinStyle or {‘miter’, ‘round’, ‘bevel’}
- set_dashes(seq)[source]¶
Set the dash sequence.
The dash sequence is a sequence of floats of even length describing the length of dashes and spaces in points.
For example, (5, 2, 1, 2) describes a sequence of 5 point and 1 point dashes separated by 2 point spaces.
See also ~.Line2D.set_gapcolor, which allows those spaces to be filled with a color.
Parameters¶
- seqsequence of floats (on/off ink in points) or (None, None)
If seq is empty or
(None, None), the linestyle will be set to solid.
- set_drawstyle(drawstyle)[source]¶
Set the drawstyle of the plot.
The drawstyle determines how the points are connected.
Parameters¶
- drawstyle{‘default’, ‘steps’, ‘steps-pre’, ‘steps-mid’, ‘steps-post’}, default: ‘default’
For ‘default’, the points are connected with straight lines.
The steps variants connect the points with step-like lines, i.e. horizontal lines with vertical steps. They differ in the location of the step:
‘steps-pre’: The step is at the beginning of the line segment, i.e. the line will be at the y-value of point to the right.
‘steps-mid’: The step is halfway between the points.
‘steps-post: The step is at the end of the line segment, i.e. the line will be at the y-value of the point to the left.
‘steps’ is equal to ‘steps-pre’ and is maintained for backward-compatibility.
For examples see /gallery/lines_bars_and_markers/step_demo.
- set_ds(drawstyle)¶
Alias for set_drawstyle.
- set_fillstyle(fs)[source]¶
Set the marker fill style.
Parameters¶
- fs{‘full’, ‘left’, ‘right’, ‘bottom’, ‘top’, ‘none’}
Possible values:
‘full’: Fill the whole marker with the markerfacecolor.
‘left’, ‘right’, ‘bottom’, ‘top’: Fill the marker half at the given side with the markerfacecolor. The other half of the marker is filled with markerfacecoloralt.
‘none’: No filling.
For examples see marker_fill_styles.
- 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¶
- gapcolorcolor or None
The color with which to fill the gaps. If None, the gaps are unfilled.
- set_in_layout(in_layout)¶
Set if artist is to be included in layout calculations, E.g. /tutorials/intermediate/constrainedlayout_guide, .Figure.tight_layout(), and
fig.savefig(fname, bbox_inches='tight').Parameters¶
in_layout : bool
- set_label(s)¶
Set a label that will be displayed in the legend.
Parameters¶
- sobject
s will be converted to a string by calling str.
- set_linestyle(ls)[source]¶
Set the linestyle of the line.
Parameters¶
- ls{‘-’, ‘–’, ‘-.’, ‘:’, ‘’, (offset, on-off-seq), …}
Possible values:
A string:
linestyle
description
'-'or'solid'solid line
'--'or'dashed'dashed line
'-.'or'dashdot'dash-dotted line
':'or'dotted'dotted line
'none','None',' ', or''draw nothing
Alternatively a dash tuple of the following form can be provided:
(offset, onoffseq)
where
onoffseqis an even length tuple of on and off ink in points. See alsoset_dashes().
For examples see /gallery/lines_bars_and_markers/linestyles.
- set_ls(ls)¶
Alias for set_linestyle.
- set_lw(w)¶
Alias for set_linewidth.
- set_marker(marker)[source]¶
Set the line marker.
Parameters¶
- markermarker style string, ~.path.Path or ~.markers.MarkerStyle
See ~matplotlib.markers for full description of possible arguments.
- set_markeredgewidth(ew)[source]¶
Set the marker edge width in points.
Parameters¶
- ewfloat
Marker edge width, in points.
- set_markersize(sz)[source]¶
Set the marker size in points.
Parameters¶
- szfloat
Marker size, in points.
- set_markevery(every)[source]¶
Set the markevery property to subsample the plot when using markers.
e.g., if
every=5, every 5-th marker will be plotted.Parameters¶
- everyNone or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]
Which markers to plot.
every=None: every point will be plotted.every=N: every N-th marker will be plotted starting with marker 0.every=(start, N): every N-th marker, starting at index start, will be plotted.every=slice(start, end, N): every N-th marker, starting at index start, up to but not including index end, will be plotted.every=[i, j, m, ...]: only markers at the given indices will be plotted.every=[True, False, True, ...]: only positions that are True will be plotted. The list must have the same length as the data points.every=0.1, (i.e. a float): markers will be spaced at approximately equal visual distances along the line; the distance along the line between markers is determined by multiplying the display-coordinate distance of the axes bounding-box diagonal by the value of every.every=(0.5, 0.1)(i.e. a length-2 tuple of float): similar toevery=0.1but the first marker will be offset along the line by 0.5 multiplied by the display-coordinate-diagonal-distance along the line.
For examples see /gallery/lines_bars_and_markers/markevery_demo.
Notes¶
Setting markevery will still only draw markers at actual data points. While the float argument form aims for uniform visual spacing, it has to coerce from the ideal spacing to the nearest available data point. Depending on the number and distribution of data points, the result may still not look evenly spaced.
When using a start offset to specify the first marker, the offset will be from the first data point which may be different from the first the visible data point if the plot is zoomed in.
If zooming in on a plot when using float arguments then the actual data points that have markers will change because the distance between markers is always determined from the display-coordinates axes-bounding-box-diagonal regardless of the actual axes data limits.
- set_mec(ec)¶
Alias for set_markeredgecolor.
- set_mew(ew)¶
Alias for set_markeredgewidth.
- set_mfc(fc)¶
Alias for set_markerfacecolor.
- set_mfcalt(fc)¶
Alias for set_markerfacecoloralt.
- set_mouseover(mouseover)¶
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
Parameters¶
mouseover : bool
See Also¶
get_cursor_data .ToolCursorPosition .NavigationToolbar2
- set_ms(sz)¶
Alias for set_markersize.
- set_path_effects(path_effects)¶
Set the path effects.
Parameters¶
path_effects : .AbstractPathEffect
- set_picker(p)[source]¶
Set the event picker details for the line.
Parameters¶
- pfloat or callable[[Artist, Event], tuple[bool, dict]]
If a float, it is used as the pick radius in points.
- set_pickradius(pickradius)[source]¶
Set the pick radius used for containment tests.
See .contains for more details.
Parameters¶
- pickradiusfloat
Pick radius, in points.
- 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
- set_sketch_params(scale=None, length=None, randomness=None)¶
Set the sketch parameters.
Parameters¶
- scalefloat, optional
The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.
- lengthfloat, optional
The length of the wiggle along the line, in pixels (default 128.0)
- randomnessfloat, optional
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
- set_snap(snap)¶
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
Parameters¶
- snapbool or None
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
- set_solid_capstyle(s)[source]¶
How to draw the end caps if the line is solid (not ~Line2D.is_dashed)
The default capstyle is :rc:`lines.solid_capstyle`.
Parameters¶
s : .CapStyle or {‘butt’, ‘projecting’, ‘round’}
- set_solid_joinstyle(s)[source]¶
How to join segments if the line is solid (not ~Line2D.is_dashed).
The default joinstyle is :rc:`lines.solid_joinstyle`.
Parameters¶
s : .JoinStyle or {‘miter’, ‘round’, ‘bevel’}
- set_zorder(level)¶
Set the zorder for the artist. Artists with lower zorder values are drawn first.
Parameters¶
level : float
- 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¶
xandysticky 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
xandylists can be modified in place as needed.Examples¶
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)