Chart2D.stack(x, ys, colors=None, labels=None)[source]#

Add a stack plot to this chart.


X coordinates of the points outlining the stacks (areas) to draw.

yslist or tuple of array_like

Size of the stacks (areas) to draw at the corresponding X coordinates. Each sequence defines the sizes of one stack (area), which are stacked on top of each other.

colorslist or tuple of ColorLike, optional

Color of the stacks (areas) drawn in this plot. Any color parsable by pyvista.Color is allowed.

labelslist or tuple of str, default: []

Label for each stack (area) drawn in this plot, as shown in the chart’s legend.


The created stack plot.


Generate a stack plot.

>>> import pyvista
>>> chart = pyvista.Chart2D()
>>> plot = chart.stack([0, 1, 2], [[2, 1, 3],[1, 2, 1]])