Using jupyter notebook, when I plot regresssions using statsmodels.api.graphics, the plots are always duplicated (see attached Capture1). When I plot a simple scatter plot using matplotlib from the same imports and data, it only plots once, as expected. Has anyone encountered this before? Can anyone suggest how to prevent the duplicates?
Please refer to code below.
Thanks,
Adam
import os
import statsmodels.api as sm
import pandas as pd
import numpy as np
from collections import defaultdict
from patsy import dmatrices
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
df = pd.DataFrame({chr(i + 97): np.random.random(size=50) for i in range(3)})
y, X = dmatrices('a ~ b + c', data=df, return_type='dataframe')
mod = sm.OLS(y, X)
res = mod.fit()
sm.graphics.plot_partregress_grid(res) # duplicate plots
plt.scatter(df.a, df.b) #single scatter plot, as expected