【问题标题】:QQ plots with scipy and matplolib. I can neither plot a legend nor change plot styles使用 scipy 和 matplotlib 绘制 QQ 图。我既不能绘制图例也不能改变情节风格
【发布时间】:2020-11-09 03:50:16
【问题描述】:

我正在用 scipy 和 Matplolib 绘制这 2 个 QQ 图。我既不能绘制图例(请参阅错误,“找不到带有标签的句柄”),也不能更改线条/plo 的样式或颜色。我怀疑是因为我无法抓住物体。

你能帮忙解决这个问题吗?

  • 添加图例
  • 将绘图颜色更改为紫色
  • 将线条样式更改为“- -” 谢谢!
fig = plt.figure()
fig.set_size_inches(10, 5)

ax1 =plt.subplot(121)
ax2=plt.subplot(122)
    
stats.probplot(arr1, dist=stats.norm, plot=ax1)   
ax1.set_title("Probability Plot",fontsize=14)
ax1.set_ylabel("Sample Quantiles",fontsize=12)
ax1.set_xlabel("Theoretical Quantiles",fontsize=12)    

stats.probplot(arr2, dist=stats.norm, plot=ax2)   
ax2.set_title("Probability Plot",fontsize=14)
ax2.set_ylabel("Sample Quantiles",fontsize=12)
ax2.set_xlabel("Theoretical Quantiles",fontsize=12)
ax2.legend()   
    
plt.show()    


【问题讨论】:

  • 什么是stats?统计模型?导入是代码的重要组成部分。啊,我明白了。 scipy.stats

标签: python matplotlib


【解决方案1】:

对于图例,您可以将字符串传递给ax2.legend() IE。 ax2.legend('string')

关于颜色和款式,您可以尝试ax.get_lines(),查看lineobject 的文档和另一篇帖子here

【讨论】:

    猜你喜欢
    • 2019-06-02
    • 1970-01-01
    • 2016-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多