pyvista.plotting.charts.BoxPlot

Contents

pyvista.plotting.charts.BoxPlot#

class BoxPlot(chart, data, colors=None, labels=None)[source]#

Class representing a box plot.

Users should typically not directly create new plot instances, but use the dedicated ChartBox class.

Parameters:
chartChartBox

The chart containing this plot.

datasequence[array_like]

Dataset(s) from which the relevant statistics will be calculated used to draw the box plot.

colorssequence[ColorLike], optional

Color of the boxes drawn in this plot. Any color parsable by pyvista.Color is allowed. If omitted (None), the default color scheme is used.

labelssequence[str], default: []

Label for each box drawn in this plot, as shown in the chart’s legend.

Examples

Create boxplots for datasets sampled from shifted normal distributions.

>>> import pyvista as pv
>>> import numpy as np
>>> rng = np.random.default_rng(
...     1
... )  # Seeded random number generator used for data generation
>>> normal_data = [rng.normal(i, size=50) for i in range(5)]
>>> chart = pv.ChartBox(
...     normal_data, labels=[f'x ~ N({i},1)' for i in range(5)]
... )
>>> chart.show()
../../../../_images/pyvista-plotting-charts-BoxPlot-2_00_00.png

Methods

BoxPlot.toggle()

Toggle the plot's visibility.

BoxPlot.update(data)

Update the plot's underlying dataset(s).

Attributes

BoxPlot.brush

Brush object controlling how shapes in this plot are filled.

BoxPlot.color

Return or set the plot's color.

BoxPlot.color_scheme

Return or set the plot's color scheme.

BoxPlot.colors

Return or set the plot's colors.

BoxPlot.data

Retrieve the datasets of which the boxplots are drawn.

BoxPlot.label

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

BoxPlot.labels

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

BoxPlot.line_style

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

BoxPlot.line_width

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

BoxPlot.pen

Pen object controlling how lines in this plot are drawn.

BoxPlot.stats

Retrieve the statistics (quartiles and extremum values) of the datasets of which the boxplots are drawn.

BoxPlot.visible

Return or set the this plot's visibility.