hvPlot.box#

hvPlot.box(y=None, by=None, **kwds)[source]#

The box plot gives you a visual idea about the locality, spread and skewness of numerical data through their quartiles. It is also known as box and whiskers plot.

box plots are most useful when grouped by additional dimensions.

Reference: https://hvplot.holoviz.org/ref/api/manual/hvplot.hvPlot.box.html

Plotting options: https://hvplot.holoviz.org/ref/plotting_options/index.html

Parameters:
ystring or sequence

Field(s) in the wide data to compute distribution from. If none is provided all numerical fields will be used.

bystring or sequence

Field in the long data to group by.

kwdsoptional

Additional keywords arguments are documented in Plotting Options. Run hvplot.help('box') for the full method documentation.

Returns:
holoviews.element.BoxWhisker / Panel object

You can print the object to study its composition and run:

import holoviews as hv
hv.help(the_holoviews_object)

to learn more about its parameters and options.

References

Backend-specific styling options#

box_alpha, box_cmap, box_color, box_fill_alpha, box_fill_color, box_hover_alpha, box_hover_color, box_hover_fill_alpha, box_hover_fill_color, box_hover_line_alpha, box_hover_line_cap, box_hover_line_color, box_hover_line_dash, box_hover_line_dash_offset, box_hover_line_join, box_hover_line_width, box_line_alpha, box_line_cap, box_line_color, box_line_dash, box_line_dash_offset, box_line_join, box_line_width, box_muted, box_muted_alpha, box_muted_color, box_muted_fill_alpha, box_muted_fill_color, box_muted_line_alpha, box_muted_line_cap, box_muted_line_color, box_muted_line_dash, box_muted_line_dash_offset, box_muted_line_join, box_muted_line_width, box_nonselection_alpha, box_nonselection_color, box_nonselection_fill_alpha, box_nonselection_fill_color, box_nonselection_line_alpha, box_nonselection_line_cap, box_nonselection_line_color, box_nonselection_line_dash, box_nonselection_line_dash_offset, box_nonselection_line_join, box_nonselection_line_width, box_selection_alpha, box_selection_color, box_selection_fill_alpha, box_selection_fill_color, box_selection_line_alpha, box_selection_line_cap, box_selection_line_color, box_selection_line_dash, box_selection_line_dash_offset, box_selection_line_join, box_selection_line_width, box_visible, box_width, cmap, outlier_alpha, outlier_color, outlier_fill_alpha, outlier_fill_color, outlier_hover_alpha, outlier_hover_color, outlier_hover_fill_alpha, outlier_hover_fill_color, outlier_hover_line_alpha, outlier_hover_line_cap, outlier_hover_line_color, outlier_hover_line_dash, outlier_hover_line_dash_offset, outlier_hover_line_join, outlier_hover_line_width, outlier_line_alpha, outlier_line_cap, outlier_line_color, outlier_line_dash, outlier_line_dash_offset, outlier_line_join, outlier_line_width, outlier_muted_alpha, outlier_muted_color, outlier_muted_fill_alpha, outlier_muted_fill_color, outlier_muted_line_alpha, outlier_muted_line_cap, outlier_muted_line_color, outlier_muted_line_dash, outlier_muted_line_dash_offset, outlier_muted_line_join, outlier_muted_line_width, outlier_nonselection_alpha, outlier_nonselection_color, outlier_nonselection_fill_alpha, outlier_nonselection_fill_color, outlier_nonselection_line_alpha, outlier_nonselection_line_cap, outlier_nonselection_line_color, outlier_nonselection_line_dash, outlier_nonselection_line_dash_offset, outlier_nonselection_line_join, outlier_nonselection_line_width, outlier_selection_alpha, outlier_selection_color, outlier_selection_fill_alpha, outlier_selection_fill_color, outlier_selection_line_alpha, outlier_selection_line_cap, outlier_selection_line_color, outlier_selection_line_dash, outlier_selection_line_dash_offset, outlier_selection_line_join, outlier_selection_line_width, whisker_alpha, whisker_color, whisker_hover_alpha, whisker_hover_color, whisker_hover_line_alpha, whisker_hover_line_cap, whisker_hover_line_color, whisker_hover_line_dash, whisker_hover_line_dash_offset, whisker_hover_line_join, whisker_hover_line_width, whisker_line_alpha, whisker_line_cap, whisker_line_color, whisker_line_dash, whisker_line_dash_offset, whisker_line_join, whisker_line_width, whisker_muted, whisker_muted_alpha, whisker_muted_color, whisker_muted_line_alpha, whisker_muted_line_cap, whisker_muted_line_color, whisker_muted_line_dash, whisker_muted_line_dash_offset, whisker_muted_line_join, whisker_muted_line_width, whisker_nonselection_alpha, whisker_nonselection_color, whisker_nonselection_line_alpha, whisker_nonselection_line_cap, whisker_nonselection_line_color, whisker_nonselection_line_dash, whisker_nonselection_line_dash_offset, whisker_nonselection_line_join, whisker_nonselection_line_width, whisker_selection_alpha, whisker_selection_color, whisker_selection_line_alpha, whisker_selection_line_cap, whisker_selection_line_color, whisker_selection_line_dash, whisker_selection_line_dash_offset, whisker_selection_line_join, whisker_selection_line_width, whisker_visible

bootstrap, boxprops, capprops, conf_intervals, flierprops, meanline, meanprops, medianprops, notch, show_caps, showfliers, showmeans, sym, whis, whiskerprops, widths

Examples#

Basic box plot#

import hvplot.pandas  # noqa
import numpy as np
import pandas as pd

df = pd.DataFrame(np.random.randn(25, 4), columns=list('ABCD'))

df.hvplot.box()

Wide data#

This example uses the tech stocks dataset to display a box plot from wide-form data, where each column represents a separate numerical series.

import hvplot.pandas # noqa

df = hvplot.sampledata.stocks("pandas")

df.hvplot.box(width=500, group_label='Stocks')

Long data#

This example uses the penguins dataset in long-form format to compare the distribution of penguin body mass across species using the by keyword. Note that the box method does not accept the x keyword.

import hvplot.pandas # noqa

df = hvplot.sampledata.penguins("pandas")

df.hvplot.box(y="body_mass_g", by="species", width=400)

by can accept a list of variables, in which case the categorical axis (here inverted with invert=True) shows the variables nested.

import hvplot.pandas # noqa

df = hvplot.sampledata.penguins("pandas")

df.hvplot.box(y='body_mass_g', by=['species', 'sex'], invert=True)

Xarray example#

import hvplot.xarray  # noqa

ds = hvplot.sampledata.air_temperature("xarray").sel(lat=[25, 50, 75])

ds.hvplot.box(y="air", by="lat")
This web page was generated from a Jupyter notebook and not all interactivity will work on this website.