I am going to create an Arima model for time series data with the following DF of 157 rows:
I am trying to establish which decomposition is best suited to my data and have produced a multiplicative and additive decomposition of the series. I have plotted the two decomposition residuals in different subplots using following code:
# produce a multiplicative and additive decomposition of the series
a = seasonal_decompose(actuals, model='a', freq=52)
m = seasonal_decompose(actuals, model='m', freq=52)
a_model = a.trend+a.seasonal
m_model = m.trend*m.seasonal
#plot the two decomposition residuals in different subplots
plt.style.use('ggplot')
plt.rcParams['figure.figsize']=(14,6)
x = actuals.index
residual_m = m.resid
plt.subplot(2,1,1)
plt.title('Multiplicative decomposition residuals')
plt.plot(x, residual_m, 'b', linewidth=2)
residual_a = a.resid
plt.tick_params(
labelbottom=False)
plt.subplot(2,1,2)
plt.title('Additive decomposition residuals')
plt.plot(x, residual_a, 'r', linewidth=2)
plt.xticks(rotation=60)
plt.show()
This produces the following charts:
As you can see the xaxis overlaps. I have searched and found a number of resolutions to reduce number of x tick marks. Whether that's to tell matplotlib the desired number of ticks using 'ax.locator_params(nbins=10, axis='x')' (this gives AttributeError: 'numpy.ndarray' object has no attribute 'locator_params'). Or when I try 'fig.autofmt_xdate()' (no effect). I think these resolutions do not work as my xaxis is the index.
Can anyone help with the correct logic? Preferabaly I just want to reduce the amount of xaxis labels but it would also be really good to space it out by every 4 bins/weeks.