Chart2D.line

Chart2D.line#

Chart2D.line(
x: VectorLikeFloat,
y: VectorLikeFloat,
*,
color: ColorLike | None = 'b',
width: float = 1.0,
style: LineStyle | None = '-',
label: str | None = '',
) → LinePlot2D[source]#

Add a line plot to this chart.

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.

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.

Returns:
plotting.charts.LinePlot2D

The created line plot.

Examples#

Download Python source code | Download Jupyter notebook

Generate a line plot.

>>> import pyvista as pv
>>> chart = pv.Chart2D()
>>> plot = chart.line([0, 1, 2], [2, 1, 3])
>>> chart.show()
../../../../_images/pyvista-Chart2D-line-de2db415c727a21c_00_00.png