MMMPlotlyFactory.contributions#
- MMMPlotlyFactory.contributions(hdi_prob=0.94, component='channel', frequency=None, round_digits=0, auto_facet=True, single_dim_facet='col', **plotly_kwargs)[source]#
Plot contributions bar chart with optional error bars and faceting.
Creates an interactive Plotly bar chart showing contributions from channels, controls, seasonality, or baseline. Automatically applies faceting for multi-dimensional MMM models.
- Parameters:
- hdi_prob
float, optional HDI probability for error bars (default: 0.94). If None, no error bars.
- component{“channel”, “control”, “seasonality”, “baseline”}
Which contribution component to plot (default: “channel”)
- frequency
str, optional Time aggregation (e.g., “monthly”, “all_time”). None = no aggregation.
- round_digits
int, default 0 Number of decimal places for rounding values in hover text.
- auto_facetbool, default
True Automatically detect and apply faceting for custom dimensions.
- single_dim_facet{“col”, “row”}, default “col”
When auto_facet is enabled and there is exactly one custom dimension, this controls whether it is applied as facet_col or facet_row.
- **plotly_kwargs
Additional Plotly Express arguments including: - title: Figure title (default: “{Component} Contributions”) - facet_row: Column for row facets (e.g., “country”) - facet_col: Column for column facets (e.g., “brand”) - facet_col_wrap: Max columns before wrapping - barmode: “group” (side-by-side) or “stack”
- hdi_prob
- Returns:
go.FigureInteractive Plotly figure
Examples
>>> # Basic channel contributions >>> fig = mmm.plot_interactive.contributions() >>> fig.show()
>>> # Contributions by country (auto-faceted) >>> fig = mmm.plot_interactive.contributions(facet_col="country") >>> fig.show()
>>> # Control contributions with custom title >>> fig = mmm.plot_interactive.contributions( ... component="control", title="Control Variable Effects" ... ) >>> fig.show()