【问题标题】:How can I specify the color of the line='s' or line=45 line drawn in a qq plot using statsmodels如何使用 statsmodels 指定在 qq 图中绘制的 line='s' 或 line=45 线的颜色
【发布时间】:2021-05-21 19:36:25
【问题描述】:
import statsmodels.api as sm
sm.qqplot(residuals, line ='s',dist='norm',color='g',fmt='.g')
plt.grid()

我无法通过使用 linecolor 等参数将“红线”的颜色更改为我选择的颜色。

【问题讨论】:

    标签: python colors statsmodels


    【解决方案1】:

    我找不到任何可以直接从sm.qqplot 更改颜色的答案。所以我尝试将绘图存储在子图中,然后从那里更改线条的颜色。

    fig, ax = plt.subplots(1, figsize=(7,4.5))
    
    sm.qqplot(data, line ='45',dist='norm',color='g',fmt='.g', ax=ax)
    ax.grid()
    ax.set_title('data_qq',fontsize=15)
    ax.xaxis.get_label().set_fontsize(12)
    ax.yaxis.get_label().set_fontsize(12)
    ax.get_lines()[1].set_color("black")
    ax.get_lines()[1].set_linewidth("2")
    

    • 我仍然想知道是否有办法在 sm.qqplot 命令中执行此操作。

    【讨论】:

      猜你喜欢
      • 2017-05-01
      • 2015-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多