pyvista.plotting.charts.LinePlot2D#

class LinePlot2D(chart, x, y, color='b', width=1.0, style='-', label='')[source]#

Class representing a 2D line plot.

Users should typically not directly create new plot instances, but use the dedicated 2D chart’s plotting methods.

Parameters:
chartChart2D

The chart containing this plot.

xarray_like

X coordinates of the points through which a line should be drawn.

yarray_like

Y coordinates of the points through which a line should be drawn.

colorColorLike, default: “b”

Color of the line drawn in this plot. Any color parsable by pyvista.Color is allowed.

widthfloat, default: 1

Width of the line drawn in this plot.

stylestr, default: “-”

Style of the line drawn in this plot. See Pen.LINE_STYLES for a list of allowed line styles.

labelstr, default: “”

Label of this plot, as shown in the chart’s legend.

Examples

Create a 2D chart plotting an approximate satellite trajectory.

>>> import pyvista as pv
>>> from pyvista import examples
>>> import numpy as np
>>> chart = pv.Chart2D()
>>> x = np.linspace(0, 1, 100)
>>> y = np.sin(6.5*x-1)
>>> _ = chart.line(x, y, "y", 4)
>>> chart.background_texture = examples.load_globe_texture()
>>> chart.hide_axes()
>>> chart.show()
../../../../_images/pyvista-plotting-charts-LinePlot2D-2_00_00.png

Methods

LinePlot2D.toggle()

Toggle the plot's visibility.

LinePlot2D.update(x, y)

Update this plot's points, through which a line is drawn.

Attributes

LinePlot2D.brush

Brush object controlling how shapes in this plot are filled.

LinePlot2D.color

Return or set the plot's color.

LinePlot2D.label

Return or set the this plot's label, as shown in the chart's legend.

LinePlot2D.line_style

Return or set the line style of all lines drawn in this plot.

LinePlot2D.line_width

Return or set the line width of all lines drawn in this plot.

LinePlot2D.pen

Pen object controlling how lines in this plot are drawn.

LinePlot2D.visible

Return or set the this plot's visibility.

LinePlot2D.x

Retrieve the X coordinates of the points through which a line is drawn.

LinePlot2D.y

Retrieve the Y coordinates of the points through which a line is drawn.