Plot_budget_allocation creates misaligned axes

The attached plot was made with plot_budget_allocation. As you can see the y axes do not align. Is this intentional, or should they match on the grid?

Hey @fountainpen

Looks odd, but I’ll need to see your code or some reproducible example to find out. I try a few stuff without success reproducing. On the other hand, I’ll recommend to play with the new multidimensional class, and the plot suite, that should be better.

pymc_marketing.mmm.multidimensional ref: MMM Multidimensional Example Notebook — Open Source Marketing Analytics Solution

Just a general note about MPL, it’s quite hard to align left and right axis gridlines. The grid always goes with the axis that it is added to (the left one in this case). See discussion here.

1 Like

@cetagostini

I’m using the following plot style formatting

az.style.use("arviz-docgrid")
plt.rcParams["figure.figsize"] = [12, 7]
plt.rcParams["figure.dpi"] = 100
# Create budget bounds
percentage_flexibility = 0.3
num_optimization_periods = 15
budget_bounds = {
    channel: [
        (1 - percentage_flexibility) * current_weekly_spend[channel], 
        (1 + percentage_flexibility) * current_weekly_spend[channel]
    ]
    for channel in channel_columns
}

# Run budget optimization
allocation_strategy, optimization_result = mmm.optimize_budget(budget=total_weekly_budget,  num_periods=num_optimization_periods,  budget_bounds=budget_bounds,  minimize_kwargs={“method”: “SLSQP”,“options”: {“ftol”: 1e-9, “maxiter”: 5000}})
model_granularity = “weekly”
response = mmm.sample_response_distribution(allocation_strategy=allocation_strategy,time_granularity=model_granularity,num_periods=num_optimization_periods,noise_level=0.05,)
fig, ax = mmm.plot_budget_allocation(samples=response, figsize=(14, 8), original_scale=True)
ax.grid()