Reputation: 69
I'm using statsmodels to compute a ARMA model with forecast. I want to change the color of the trend but I get an error:
fig = arma_mod30.plot_predict('2011', '2015', color='#FF6600', dynamic=True, ax=ax, plot_insample=False) TypeError: plot_predict() got an unexpected keyword argument 'color'
the plotting code:
fig, ax = plt.subplots(figsize=(12, 8))
ax = d.ix['2009':].plot(ax=ax,label='Trend',color='#0000FF')
fig = arma_mod30.plot_predict('2011', '2018', color='#FF6600', dynamic=True, ax=ax, plot_insample=False)
plt.title('Forecast Trend')
plt.xlabel('year')
plt.ylabel('value')
plt.savefig('Output.png')
Upvotes: 1
Views: 9019
Reputation: 31399
This example is based on the example code of plot_predict
from statsmodels
' documentation:
Here I use the mpl.rc_context()
to temporarily change the color cycle for the figure.
with mpl.rc_context():
mpl.rc('axes', color_cycle=['#0000FF', '#FF6600'])
dta = sm.datasets.sunspots.load_pandas().data[['SUNACTIVITY']]
dta.index = pd.DatetimeIndex(start='1700', end='2009', freq='A')
res = sm.tsa.ARMA(dta, (3, 0)).fit()
fig, ax = plt.subplots()
ax = dta.ix['1950':].plot(ax=ax)
fig = res.plot_predict('1990', '2012', dynamic=True, ax=ax,
plot_insample=False)
It's probably a little hackish, but it should solve your problem:
Upvotes: 1