dabl.plot.mosaic_plot

dabl.plot.mosaic_plot(data, rows, cols, vary_lightness=False, ax=None, legend=True)[source]

Create a mosaic plot from a dataframe.

Right now only horizontal mosaic plots are supported, i.e. rows are prioritized over columns.

Parameters
datapandas data frame

Data to tabulate.

rowscolumn specifier

Column in data to tabulate across rows.

colscolumn specifier

Column in data to use to subpartition rows.

vary_lightnessbool, default=False

Whether to vary lightness across categories.

axmatplotlib axes or None

Axes to plot into.

legendboolean, default=True

Whether to create a legend.

Examples

>>> from dabl.datasets import load_titanic
>>> data = load_titanic()
>>> mosaic_plot(data, 'sex', 'survived')