matplotlib.lines.Line2D(xdata, ydata, linewidth=None, linestyle=None, color=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: matplotlib.artist.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 xdata, ydata.
The kwargs are Line2D properties:
Property Description agg_filtera filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alphafloat animatedbool antialiasedbool clip_boxBboxclip_onbool clip_path[( Path,Transform) |Patch| None]colorcolor containscallable dash_capstyle{'butt', 'round', 'projecting'} dash_joinstyle{'miter', 'round', 'bevel'} dashessequence of floats (on/off ink in points) or (None, None) drawstyle{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'} figureFigurefillstyle{'full', 'left', 'right', 'bottom', 'top', 'none'} gidstr in_layoutbool labelobject linestyle{'-', '--', '-.', ':', '', (offset, on-off-seq), ...} linewidthfloat markerunknown markeredgecolorcolor markeredgewidthfloat markerfacecolorcolor markerfacecoloraltcolor markersizefloat markeveryunknown path_effectsAbstractPathEffectpickerfloat or callable[[Artist, Event], Tuple[bool, dict]] pickradiusfloat rasterizedbool or None sketch_params(scale: float, length: float, randomness: float) snapbool or None solid_capstyle{'butt', 'round', 'projecting'} solid_joinstyle{'miter', 'round', 'bevel'} transformmatplotlib.transforms.Transform urlstr visiblebool xdata1D array ydata1D array zorderfloat
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.
contains(mouseevent)[source]¶Test whether the mouse event occurred on the line. The pick
radius determines the precision of the location test (usually
within five points of the value). Use
get_pickradius() or
set_pickradius() to view or
modify it.
Returns True if any values are within the radius along with
{'ind': pointlist}, where pointlist is the set of points
within the radius.
TODO: sort returned indices by distance
drawStyleKeys = ['default', 'steps-mid', 'steps-pre', 'steps-post', 'steps']¶drawStyles = {'default': '_draw_lines', 'steps': '_draw_steps_pre', 'steps-mid': '_draw_steps_mid', 'steps-post': '_draw_steps_post', 'steps-pre': '_draw_steps_pre'}¶fillStyles = ('full', 'left', 'right', 'bottom', 'top', 'none')¶filled_markers = ('o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd', 'P', 'X')¶get_aa(*args, **kwargs)¶alias for get_antialiased
get_ls(*args, **kwargs)¶alias for get_linestyle
get_lw(*args, **kwargs)¶alias for get_linewidth
get_mec(*args, **kwargs)¶alias for get_markeredgecolor
get_mew(*args, **kwargs)¶alias for get_markeredgewidth
get_mfc(*args, **kwargs)¶alias for get_markerfacecolor
get_mfcalt(*args, **kwargs)¶alias for get_markerfacecoloralt
get_ms(*args, **kwargs)¶alias for get_markersize
get_window_extent(renderer)[source]¶Get the axes bounding box in display space. 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.
lineStyles = {'': '_draw_nothing', ' ': '_draw_nothing', '-': '_draw_solid', '--': '_draw_dashed', '-.': '_draw_dash_dot', ':': '_draw_dotted', 'None': '_draw_nothing'}¶markers = {'.': 'point', ',': 'pixel', 'o': 'circle', 'v': 'triangle_down', '^': 'triangle_up', '<': 'triangle_left', '>': 'triangle_right', '1': 'tri_down', '2': 'tri_up', '3': 'tri_left', '4': 'tri_right', '8': 'octagon', 's': 'square', 'p': 'pentagon', '*': 'star', 'h': 'hexagon1', 'H': 'hexagon2', '+': 'plus', 'x': 'x', 'D': 'diamond', 'd': 'thin_diamond', '|': 'vline', '_': 'hline', 'P': 'plus_filled', 'X': 'x_filled', 0: 'tickleft', 1: 'tickright', 2: 'tickup', 3: 'tickdown', 4: 'caretleft', 5: 'caretright', 6: 'caretup', 7: 'caretdown', 8: 'caretleftbase', 9: 'caretrightbase', 10: 'caretupbase', 11: 'caretdownbase', 'None': 'nothing', None: 'nothing', ' ': 'nothing', '': 'nothing'}¶set_aa(*args, **kwargs)¶alias for set_antialiased
set_dash_capstyle(s)[source]¶Set the cap style for dashed linestyles.
| Parameters: |
|
|---|
set_dash_joinstyle(s)[source]¶Set the join style for dashed linestyles.
| Parameters: |
|
|---|
set_dashes(seq)[source]¶Set the dash sequence, sequence of dashes with on off ink in points. If seq is empty or if seq = (None, None), the linestyle will be set to solid.
| Parameters: |
|
|---|
set_drawstyle(drawstyle)[source]¶Set the drawstyle of the plot
'default' connects the points with lines. The steps variants produce step-plots. 'steps' is equivalent to 'steps-pre' and is maintained for backward-compatibility.
| Parameters: |
|
|---|
set_fillstyle(fs)[source]¶Set the marker fill style; 'full' means fill the whole marker. 'none' means no filling; other options are for half-filled markers.
| Parameters: |
|
|---|
set_linestyle(ls)[source]¶Set the linestyle of the line (also accepts drawstyles,
e.g., 'steps--')
| linestyle | description |
|---|---|
'-' or 'solid' |
solid line |
'--' or 'dashed' |
dashed line |
'-.' or 'dashdot' |
dash-dotted line |
':' or 'dotted' |
dotted line |
'None' |
draw nothing |
' ' |
draw nothing |
'' |
draw nothing |
'steps' is equivalent to 'steps-pre' and is maintained for backward-compatibility.
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.
See also
set_drawstyle()| Parameters: |
|
|---|
set_ls(*args, **kwargs)¶alias for set_linestyle
set_lw(*args, **kwargs)¶alias for set_linewidth
set_marker(marker)[source]¶Set the line marker.
| Parameters: |
|
|---|
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: |
|
|---|
Notes
Setting the markevery property will only show markers at actual data points. When using float arguments to set the markevery property on irregularly spaced data, the markers will likely not appear evenly spaced because the actual data points do not coincide with the theoretical spacing between markers.
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(*args, **kwargs)¶alias for set_markeredgecolor
set_mew(*args, **kwargs)¶alias for set_markeredgewidth
set_mfc(*args, **kwargs)¶alias for set_markerfacecolor
set_mfcalt(*args, **kwargs)¶alias for set_markerfacecoloralt
set_ms(*args, **kwargs)¶alias for set_markersize
set_picker(p)[source]¶Sets the event picker details for the line.
| Parameters: |
|
|---|
set_pickradius(d)[source]¶Set the pick radius used for containment tests.
| Parameters: |
|
|---|
set_solid_capstyle(s)[source]¶Set the cap style for solid linestyles.
| Parameters: |
|
|---|
set_solid_joinstyle(s)[source]¶Set the join style for solid linestyles.
| Parameters: |
|
|---|
set_transform(t)[source]¶set the Transformation instance used by this artist
| Parameters: |
|
|---|
validCap = ('butt', 'round', 'projecting')¶validJoin = ('miter', 'round', 'bevel')¶zorder = 2¶matplotlib.lines.Line2D¶