pyvista.plotting.charts.LinePlot2D#

class LinePlot2D(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
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.

colorcolor_like, optional

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

widthfloat, optional

Width of the line drawn in this plot. Defaults to 1.

stylestr, optional

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

labelstr, optional

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

Examples

Create a 2D chart plotting an approximate satellite trajectory.

>>> import pyvista
>>> from pyvista import examples
>>> import numpy as np
>>> chart = pyvista.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-1_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.