MMMPlotSuite.budget_allocation#
- MMMPlotSuite.budget_allocation(samples, scale_factor=None, figsize=(12, 6), ax=None, original_scale=True)[source]#
Plot the budget allocation and channel contributions.
Creates a bar chart comparing allocated spend and channel contributions for each channel. If additional dimensions besides ‘channel’ are present, creates a subplot for each combination of these dimensions.
- Parameters:
- samples
xr.Dataset
The dataset containing the channel contributions and allocation values. Expected to have ‘channel_contribution’ and ‘allocation’ variables.
- scale_factor
float
, optional Scale factor to convert to original scale, if original_scale=True. If None and original_scale=True, assumes scale_factor=1.
- figsize
tuple
[float
,float
], optional The size of the figure to be created. Default is (12, 6).
- ax
plt.Axes
, optional The axis to plot on. If None, a new figure and axis will be created. Only used when no extra dimensions are present.
- original_scalebool, optional
A boolean flag to determine if the values should be plotted in their original scale. Default is True.
- samples
- Returns:
- fig
matplotlib.figure.Figure
The Figure object containing the plot.
- axes
matplotlib.axes.Axes
ornumpy.ndarray
ofmatplotlib.axes.Axes
The Axes object with the plot, or array of Axes for multiple subplots.
- fig