| [ Web Proxy ] |
| Viewing: https://matplotlib.org/devdocs/api/_as_gen/matplotlib.lines.Line2D.html | [Back] [Original] |
Bases: Artist
A 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.
Create a Line2D instance with x and y data in sequences of
xdata, ydata.
Additional keyword arguments are Line2D properties:
Property
Description
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
float or None
bool
antialiasedoraabool
BboxBaseor Nonebool
Patch or (Path, Transform) or None
CapStyleor {'butt', 'projecting', 'round'}
JoinStyleor {'miter', 'round', 'bevel'}sequence of floats (on/off ink in points) or (None, None)
(2, N) array or two 1D arrays
{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'
{'full', 'left', 'right', 'bottom', 'top', 'none'}
color or None
str
bool
object
float
marker style string,
PathorMarkerStylefloat
markersizeormsfloat
None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]
bool
list of
AbstractPathEffectfloat or callable[[Artist, Event], tuple[bool, dict]]
float
bool
(scale: float, length: float, randomness: float)
bool or None
CapStyleor {'butt', 'projecting', 'round'}
JoinStyleor {'miter', 'round', 'bevel'}unknown
str
bool
1D array
1D array
float
See set_linestyle() for a description of the line styles,
set_marker() for a description of the markers, and
set_drawstyle() for a description of the draw styles.
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
get_pickradius or set_pickradius to get or set
the pick radius.
MouseEventWhether any values are within the radius.
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
Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (Artist.get_visible
returns False).
RendererBase subclass.Notes
This method is overridden in the Artist subclasses.
Alias for get_antialiased.
Return the CapStyle for dashed lines.
See also set_dash_capstyle.
Return the JoinStyle for dashed lines.
See also set_dash_joinstyle.
Return the line data as an (xdata, ydata) pair.
If orig is True, return the original data.
Return the drawstyle.
See also set_drawstyle.
Alias for get_drawstyle.
Return the marker fill style.
See also set_fillstyle.
Return the line gapcolor.
See also set_gapcolor.
Return the linestyle.
See also set_linestyle.
Return the linewidth in points.
See also set_linewidth.
Alias for get_linestyle.
Alias for get_linewidth.
Return the line marker.
See also set_marker.
Return the marker edge color.
See also set_markeredgecolor.
Return the marker edge width in points.
See also set_markeredgewidth.
Return the marker face color.
See also set_markerfacecolor.
Return the alternate marker face color.
See also set_markerfacecoloralt.
Return the marker size in points.
See also set_markersize.
Return the markevery setting for marker subsampling.
See also set_markevery.
Alias for get_markeredgecolor.
Alias for get_markeredgewidth.
Alias for get_markerfacecolor.
Alias for get_markerfacecoloralt.
Alias for get_markersize.
Return the pick radius used for containment tests.
See contains for more details.
Return the CapStyle for solid lines.
See also set_solid_capstyle.
Return the JoinStyle for solid lines.
See also set_solid_joinstyle.
Get the artist's bounding box in display space, ignoring clipping.
The bounding box's width and height are non-negative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call
savefig or draw_without_rendering to have
Matplotlib compute the rendered size.
RendererBase, optionalRenderer used to draw the figure (i.e. fig.canvas.get_renderer()).
See also
Artist.get_tightbboxGet the artist bounding box, taking clipping into account.
Return the xdata.
If orig is True, return the original data, else the processed data.
Return the ydata.
If orig is True, return the original data, else the processed data.
Return whether line has a dashed linestyle.
A custom linestyle is assumed to be dashed, we do not inspect the
onoffseq directly.
See also set_linestyle.
Return the pick radius used for containment tests.
See contains for more details.
[Deprecated]
Notes
Deprecated since version 3.12: Use recache(always=True) instead.
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
Property
Description
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
float or None
bool
bool
BboxBaseor Nonebool
Patch or (Path, Transform) or None
CapStyleor {'butt', 'projecting', 'round'}
JoinStyleor {'miter', 'round', 'bevel'}sequence of floats (on/off ink in points) or (None, None)
(2, N) array or two 1D arrays
{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'
{'full', 'left', 'right', 'bottom', 'top', 'none'}
color or None
str
bool
object
float
marker style string,
PathorMarkerStylefloat
float
None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]
bool
list of
AbstractPathEffectfloat or callable[[Artist, Event], tuple[bool, dict]]
float
bool
(scale: float, length: float, randomness: float)
bool or None
CapStyleor {'butt', 'projecting', 'round'}
JoinStyleor {'miter', 'round', 'bevel'}unknown
str
bool
1D array
1D array
float
Alias for set_antialiased.
How to draw the end caps if the line is is_dashed.
The default capstyle is rcParams["lines.dash_capstyle"] (default: <CapStyle.butt: 'butt'>).
CapStyle or {'butt', 'projecting', 'round'}How to join segments of the line if it is_dashed.
The default joinstyle is rcParams["lines.dash_joinstyle"] (default: <JoinStyle.round: 'round'>).
JoinStyle or {'miter', 'round', 'bevel'}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 set_gapcolor, which allows those spaces to be
filled with a color.
If seq is empty or (None, None), the linestyle will be set
to solid.
Set the drawstyle of the plot.
The drawstyle determines how the points are connected.
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 Step Demo.
Alias for set_drawstyle.
Set the marker fill style.
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 a color to fill the gaps in the dashed line style.
Note
Striped lines are created by drawing two interleaved dashed lines. There can be overlaps between those two, which may result in artifacts when using transparency.
This functionality is experimental and may change.
The color with which to fill the gaps. If None, the gaps are unfilled.
Set the linestyle of the line.
Possible values:
A string:
linestyle |
description |
|---|---|
|
solid line |
|
dashed line |
|
dash-dotted line |
|
dotted line |
|
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.
See also set_dashes().
For examples see Linestyles.
Alias for set_linestyle.
Alias for set_linewidth.
Set the line marker.
Path or MarkerStyleSee markers for full description of possible
arguments.
Set the marker edge width in points.
Marker edge width, in points.
Set the marker size in points.
Marker size, in points.
Set the markevery property to subsample the plot when using markers.
e.g., if every=5, every 5-th marker will be plotted.
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
to every=0.1 but 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 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 along the drawn line to the nearest available data point. Depending on the number and distribution of data points, and on how jagged the line is, the result may still not look evenly spaced along the x- or y-axis.
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.
Alias for set_markeredgecolor.
Alias for set_markeredgewidth.
Alias for set_markerfacecolor.
Alias for set_markerfacecoloralt.
Alias for set_markersize.
Set the event picker details for the line.
If a float, it is used as the pick radius in points.
Set the pick radius used for containment tests.
See contains for more details.
Pick radius, in points.
How to draw the end caps if the line is solid (not is_dashed)
The default capstyle is rcParams["lines.solid_capstyle"] (default: <CapStyle.projecting: 'projecting'>).
CapStyle or {'butt', 'projecting', 'round'}How to join segments if the line is solid (not is_dashed).
The default joinstyle is rcParams["lines.solid_joinstyle"] (default: <JoinStyle.round: 'round'>).
JoinStyle or {'miter', 'round', 'bevel'}matplotlib.lines.Line2D#SkewT-logP diagram: using transforms and custom projections
| Web Proxy Viewer | New URL | Original Page |