I have found and adapted the following code snippets for generating diagnostic plots for linear regression. This is currently done using the following functions:
def residual_plot(some_values):
plot_lm_1 = plt.figure(1)
plot_lm_1 = sns.residplot()
plot_lm_1.axes[0].set_title('title')
plot_lm_1.axes[0].set_xlabel('label')
plot_lm_1.axes[0].set_ylabel('label')
plt.show()
def qq_plot(residuals):
QQ = ProbPlot(residuals)
plot_lm_2 = QQ.qqplot()
plot_lm_2.axes[0].set_title('title')
plot_lm_2.axes[0].set_xlabel('label')
plot_lm_2.axes[0].set_ylabel('label')
plt.show()
which are called with something like:
plot1 = residual_plot(value_set1)
plot2 = qq_plot(value_set1)
plot3 = residual_plot(value_set2)
plot4 = qq_plot(value_set2)
How can I create subplots
so that these 4 plots are displayed in a 2x2 grid?
I have tried using:
fig, axes = plt.subplots(2,2)
axes[0,0].plot1
axes[0,1].plot2
axes[1,0].plot3
axes[1,1].plot4
plt.show()
but receive the error:
AttributeError: 'AxesSubplot' object has no attribute 'plot1'
Should I set up the axes attributes from within the functions or where else?