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:
- samples
xr.Dataset
The dataset containing the samples of channel contributions. Expected to have ‘channel_contribution’ variable with dimensions ‘channel’, ‘date’, and ‘sample’.
- 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.
- lower_quantile
float
, optional The lower quantile for the uncertainty interval. Default is 0.025.
- upper_quantile
float
, 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.
- figsize
tuple
[float
,float
], optional The size of the figure to be created. Default is (10, 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.
- 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