1234567891011121314151617181920212223 |
- def reg_resid_plot(df="dataframe", yhat=None, resid=None, stdresid=None, dim=(6, 4), colordot='#4a4e4d',
- colorline='#2ab7ca', r=300, ar=0, dotsize=6, valphaline=1, valphadot=1, linewidth=1,
- markerdot="o", show=False, figtype='png', theme=None):
- if theme == 'dark':
- general.dark_bg()
- fig, ax = plt.subplots(figsize=dim)
- if resid is not None:
- plt.scatter(df[yhat], df[resid], color=colordot, s=dotsize, alpha=valphadot, marker=markerdot)
- plt.axhline(y=0, color=colorline, linestyle='--', linewidth=linewidth, alpha=valphaline)
- plt.xlabel("Fitted")
- plt.ylabel("Residuals")
- general.get_figure(show, r, figtype, 'resid_plot', theme)
- else:
- print ("Error: Provide residual data")
- if stdresid is not None:
- plt.scatter(df[yhat], df[stdresid], color=colordot, s=dotsize, alpha=valphadot, marker=markerdot)
- plt.axhline(y=0, color=colorline, linestyle='--', linewidth=linewidth, alpha=valphaline)
- plt.xlabel("Fitted")
- plt.ylabel("Standardized Residuals")
- general.get_figure(show, r, figtype, 'std_resid_plot', theme)
- else:
- print ("Error: Provide standardized residual data")
|