milkviz.stacked_bar#

milkviz.stacked_bar(data, group=None, value=None, stacked=None, *, orient='v', group_order=None, stacked_order=None, percentage=False, barwidth=0.8, cmap=None, colors=None, show_values=False, props=None, legend_kw=None, ax=None) Axes#

Stacked bar plot

Parameters
datapd.DataFrame

The data used to plot

groupstr

The column used to group

valuestr

The column that contains numeric values for plotting

stackedstr

The column to plot as stack

orient“v” or “h”

The orientation of the plot

group_order
stacked_order
percentagebool

Normalize stack to 1, ensure all stacks have same height

cmap
colorsarray, mapping

Either array that represents colors or a dict that map types to colors

barwidthfloat

The width of stacked bar, should be in (0, 1)

show_valuesbool

Whether to display values of each block, or you can pass in a function to tell when to display like lambda x: x > 100 will only display when value exceed 100

propsdict

Use to style text, pass to matplotlib.axes.Axes.text()

legend_kwdict

The options to configure legend

ax
Returns
Axes