【问题标题】:Q-Q plot in one figure instead of 9 subplots pythonQQ图在一个图中而不是9个子图python
【发布时间】:2018-11-19 07:42:02
【问题描述】:

我有一个代码,可以在其中绘制九只股票的 Q-Q 分布 (iN = 9)。所以我有一个带有 9 个子图的数字。但是,我想将这 9 个子图合并为一个大图,所以一个图。目前我的代码是:

fig, axes = plt.subplots(nrows=6, ncols=2, figsize=(9,20))
ax= axes.flatten()
for i in range(iN):
    sm.qqplot((mY[i,:]), fit = True, line='q', ax=ax[i])
    ax[i].legend(asX2[i])
plt.savefig('NSE_mY_QQplot_norm.jpg', bbox_inches='tight')
plt.show() 

所以我把代码改成这样:

 fig= plt.figure(figsize=(9,20))
 for i in range(iN):
     sm.qqplot((mY[i,:]), fit = True, line='q', ax=ax[i])
     ax[i].legend(asX2[i])
 plt.savefig('NSE_mY_QQplot_norm.jpg', bbox_inches='tight')
 plt.show()

但是我根本没有得到一个数字。运行后只有这个注释:
matplotlib.figure.Figure 在 0x1c22325828

不胜感激,谢谢!!

【问题讨论】:

  • 您是否尝试过将plt.subplots()nrows = 1ncols = 1 一起使用?当然,axes 中只有一个元素,因此您不必将其展平并编制索引。

标签: python matplotlib plot distribution figure


【解决方案1】:

我还没有能力发表评论,所以我会留下这个作为答案。几天前(远在您之后)提出了一个类似的问题,似乎给出了您想要的结果:Python: Multiple QQ-Plot

【讨论】:

    猜你喜欢
    • 2021-12-05
    • 2020-04-28
    • 2015-05-13
    • 1970-01-01
    • 2021-05-22
    • 2011-05-08
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    相关资源
    最近更新 更多