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:
- chart
Chart2D
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.
- color
ColorLike
, default: “b” Color of the line drawn in this plot. Any color parsable by
pyvista.Color
is allowed.- width
float
, default: 1 Width of the line drawn in this plot.
- style
str
, default: “-” Style of the line drawn in this plot. See Pen.LINE_STYLES for a list of allowed line styles.
- label
str
, default: “” Label of this plot, as shown in the chart’s legend.
- chart
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()
Methods
Toggle the plot's visibility.
LinePlot2D.update
(x, y)Update this plot's points, through which a line is drawn.
Attributes
Brush object controlling how shapes in this plot are filled.
Return or set the plot's color.
Return or set the this plot's label, as shown in the chart's legend.
Return or set the line style of all lines drawn in this plot.
Return or set the line width of all lines drawn in this plot.
Pen object controlling how lines in this plot are drawn.
Return or set the this plot's visibility.
Retrieve the X coordinates of the points through which a line is drawn.
Retrieve the Y coordinates of the points through which a line is drawn.