• seasonal_decompose plot figsize


    You can plot a bigger graph by plotting each graph separately. For example,

    fig, (ax1,ax2,ax3) = plt.subplots(3,1, figsize=(15,8))
    res.trend.plot(ax=ax1)
    res.resid.plot(ax=ax2)
    res.seasonal.plot(ax=ax3)

    Just use that before the plot and you will be fine:

    pylab.rcParams['figure.figsize'] = (14, 9)

    import matplotlib.pyplot as plt
    import statsmodels.api as sm
    
    dta = sm.datasets.co2.load_pandas().data
    dta.co2.interpolate(inplace=True)
    res = sm.tsa.seasonal_decompose(dta.co2)
    
    def plotseasonal(res, axes ):
        res.observed.plot(ax=axes[0], legend=False)
        axes[0].set_ylabel('Observed')
        res.trend.plot(ax=axes[1], legend=False)
        axes[1].set_ylabel('Trend')
        res.seasonal.plot(ax=axes[2], legend=False)
        axes[2].set_ylabel('Seasonal')
        res.resid.plot(ax=axes[3], legend=False)
        axes[3].set_ylabel('Residual')
    
    
    dta = sm.datasets.co2.load_pandas().data
    dta.co2.interpolate(inplace=True)
    res = sm.tsa.seasonal_decompose(dta.co2)
    
    fig, axes = plt.subplots(ncols=3, nrows=4, sharex=True, figsize=(12,5))
    
    plotseasonal(res, axes[:,0])
    plotseasonal(res, axes[:,1])
    plotseasonal(res, axes[:,2])
    
    plt.tight_layout()
    plt.show()

    REF

    https://gist.github.com/balzer82/5cec6ad7adc1b550e7ee

    https://stackoverflow.com/questions/45184055/how-to-plot-multiple-seasonal-decompose-plots-in-one-figure

  • 相关阅读:
    吉哥系列故事――恨7不成妻
    K
    F
    树状数组
    34.在排序数组中查找元素的第一个和最后一个位置--二分查找
    CSS选择器及其权重
    CSS布局 圣杯和双飞翼
    983. 最低票价 -- 动态规划
    合并k个排序链表 二分
    面试题 16.03. 交点
  • 原文地址:https://www.cnblogs.com/emanlee/p/14482292.html
Copyright © 2020-2023  润新知