milkviz.stacked_bar(data: pd.DataFrame = None, x: str | List | np.ndarray = None, y: str | List | np.ndarray = None, stacked: Union[str, np.ndarray, None] = None, orient: str = 'v', percentage: bool = False, cmap: Union[str, Colormap, None] = None, show_values: bool | Callable = False, legend_kw: Dict = None, ax: mpl.axes.Axes = None, **kwargs) Axes#

Stacked bar plot

  • data – Data use to plot, should be a dataframe

  • x – Either a key in data or a numpy array

  • y – Either a key in data or a numpy array

  • stacked – Which columns to plot as stacked type

  • orient – “v” or “h”

  • percentage – Normalize value to 1

  • cmap – The colormap to be used, either a cmap name or a, default: “echarts”, a custom milkviz palette

  • show_values – 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

  • legend_kw – The options to configure legend

  • ax – Pre-existing axes for the plot. Or a new one will be created.

  • **kwargs – Pass to seaborn.barplot


A matplotlib.axes.Axes instance