Arviz won't apply to matplotlib ax (plot_forest, plot_kde)

I am trying to use plot forest method to apply to my matplot lib axes. However it appears that only 1 ridgeplot will work and anything else won’t plot. I can switch the order such as to plot on ax2 first but anything after the first plot wont show. I can’t even set_tittle after I plot.

Apparently its any arviz plot, even plot_kde has the same problem.

fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(18, 5))

az.plot_forest(trace_Q, kind='ridgeplot', var_names="alpha", combined=True, ax=ax1)
az.plot_forest(trace_Q, kind='ridgeplot', var_names="beta", combined=True, ax=ax2)
az.plot_forest(trace_Q, kind='ridgeplot', var_names="gamma", combined=True, ax=ax3)

Arviz: 0.11.2
pymc3: 3.11.1
matplotlib: 3.3.4

I am not able to reproduce the error, I used the following code:

idata = az.load_arviz_data("centered_eight")
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(18, 5))

az.plot_forest(idata, kind='ridgeplot', var_names="tau", combined=True, ax=ax1)
az.plot_forest(idata, kind='ridgeplot', var_names="mu", combined=True, ax=ax2)
az.plot_forest(idata, kind='ridgeplot', var_names="theta", combined=True, ax=ax3)

to generate

How are you executing the code? Could you have the rcParam set to true? arviz/arvizrc.template at main · arviz-devs/arviz · GitHub

1 Like

I couldn’t replicated your plot with the code you gave.

I have not modified the rcParams in matplotlib. They are default.

Is this in jupyter? what backend are you using? Do you have any extensions loaded?

What happens when you run

fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(18, 5))
x = np.linspace(0, 1)
y = np.random.normal(loc=x)

ax1.plot(x, y)
ax2.plot(x, y)
ax3.plot(x, y)

That code works fine. You were right about the rcParams. I apologize for wasting your time. It was tucked way up at the top and I’m not even sure why or where I got that code from or for.

az.rcParams[""] = True 


1 Like