简体   繁体   English

如何使用 statsmodels 指定在 qq plot 中绘制的 line='s' 或 line=45 线的颜色

[英]How can I specify the color of the line='s' or line=45 line drawn in a qq plot using statsmodels

import statsmodels.api as sm
sm.qqplot(residuals, line ='s',dist='norm',color='g',fmt='.g')
plt.grid()

QQ图

I am unable to change the color of the "red line" to a color of my choice by using arguments like linecolor and such.我无法通过使用 arguments (如linecolor等)将“红线”的颜色更改为我选择的颜色。

I could not find any answer which could change the color from sm.qqplot directly.我找不到任何可以直接从sm.qqplot更改颜色的答案。 So I tried by storing the plot in a subplot and then changing the color of the line from there.因此,我尝试将 plot 存储在子图中,然后从那里更改线条的颜色。

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")

预期线颜色改变的图

  • I am still interested to know if there is a way to do this from within sm.qqplot command.我仍然很想知道是否有办法从sm.qqplot命令中执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM