在jupyter笔记本中并排显示statsmodels plot_acf和plot_pacf [英] displaying statsmodels plot_acf and plot_pacf side by side in a jupyter notebook

查看:85
本文介绍了在jupyter笔记本中并排显示statsmodels plot_acf和plot_pacf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何并排显示 plot_acf plot_pacf 吗?我正在为 show = False 参数和matplotlib疯狂的对象模型而苦苦挣扎...

can someone show me how to display plot_acf and plot_pacf side by side? I'm struggling with the show=False arguments and matplotlib crazy object model...

推荐答案

您可以尝试使用 plt.subplot .这是一个简短的示例,其中包含statsmodel中的数据集以指导您.希望对您有所帮助.

You can try using plt.subplot. Here is a short example with a data set from statsmodel to guide you. I hope it is helpful.

代码

import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.api as sm

dta = sm.datasets.sunspots.load_pandas().data
dta.index = pd.Index(sm.tsa.datetools.dates_from_range('1700', '2008'))
del dta["YEAR"]
#print if you want to visualize
#print(dta.head())

fig, ax = plt.subplots(1,2,figsize=(10,5))
sm.graphics.tsa.plot_acf(dta.values.squeeze(), lags=40, ax=ax[0])
sm.graphics.tsa.plot_pacf(dta.values.squeeze(), lags=40, ax=ax[1])
plt.show()

Jupyter中的输出

Output in Jupyter

这篇关于在jupyter笔记本中并排显示statsmodels plot_acf和plot_pacf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆