MMMPlotSuite.allocated_contribution_by_channel_over_time#

MMMPlotSuite.allocated_contribution_by_channel_over_time(samples, scale_factor=None, lower_quantile=0.025, upper_quantile=0.975, original_scale=True, figsize=(10, 6), ax=None)[source]#

Plot the allocated contribution by channel with uncertainty intervals.

This function visualizes the mean allocated contributions by channel along with the uncertainty intervals defined by the lower and upper quantiles. If additional dimensions besides ‘channel’, ‘date’, and ‘sample’ are present, creates a subplot for each combination of these dimensions.

Parameters:
samplesxr.Dataset

The dataset containing the samples of channel contributions. Expected to have ‘channel_contribution’ variable with dimensions ‘channel’, ‘date’, and ‘sample’.

scale_factorfloat, optional

Scale factor to convert to original scale, if original_scale=True. If None and original_scale=True, assumes scale_factor=1.

lower_quantilefloat, optional

The lower quantile for the uncertainty interval. Default is 0.025.

upper_quantilefloat, optional

The upper quantile for the uncertainty interval. Default is 0.975.

original_scalebool, optional

If True, the contributions are plotted on the original scale. Default is True.

figsizetuple[float, float], optional

The size of the figure to be created. Default is (10, 6).

axplt.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.

Returns:
figmatplotlib.figure.Figure

The Figure object containing the plot.

axesmatplotlib.axes.Axes or numpy.ndarray of matplotlib.axes.Axes

The Axes object with the plot, or array of Axes for multiple subplots.