# Large Plot
fig = plt.determine(figsize=(16,4))
plt.plot(check, label='Check', shade='#4ac2fb')
plt.plot(all_predictions[(0,1,0)], label='Predictions', shade='#ff4e97')
plt.legend(frameon=True, loc=1, ncol=1, fontsize=10, borderpad=.6)
plt.title('Arima Predictions', fontSize=15)
plt.xlabel('Days', fontSize=13)
plt.ylabel('Returns', fontSize=13)
# Arrow
plt.annotate('',
xy=(15, 0.05),
xytext=(150, .2),
fontsize=10,
arrowprops={'width':0.4,'headwidth':7,'shade':'#333333'}
)
# Patch
ax = fig.add_subplot(1, 1, 1)
rect = patches.Rectangle((0,-.05), 30, .1, ls='--', lw=2, facecolor='y', edgecolor='okay', alpha=.5)
ax.add_patch(rect)
# Small Plot
plt.axes([.25, 1, .2, .5])
plt.plot(check[:30], shade='#4ac2fb')
plt.plot(all_predictions[(0,1,0)][:30], shade='#ff4e97')
plt.tick_params(axis='each', labelbottom=False, labelleft=False)
plt.title('Lag')
plt.present()
This Python code makes use of the Matplotlib library to generate a visualization evaluating check knowledge and predictions, probably from an ARIMA mannequin, as advised by the determine title “Arima Predictions.” The visualization contains a major plot and a smaller inset plot, each displaying time sequence knowledge, presumably representing monetary returns over a interval of days.
The code begins by establishing a predominant determine with dimensions 16 inches broad and 4 inches tall utilizing plt.determine(figsize=(16,4)). Two traces are then plotted on this determine: one representing ‘Check’ knowledge in mild blue (#4ac2fb) and the opposite representing ‘Predictions’ in pink (#ff4e97). The info for these traces is sourced from the variables check and all_predictions[(0,1,0)], the place all_predictions seems to be a multi-dimensional array, and (0,1,0) indexes a selected subset. The x-axis represents ‘Days’ and the y-axis represents ‘Returns.’ A legend is included for readability, together with applicable title and axis labels.
To focus on a selected area of curiosity, an annotation is added utilizing plt.annotate, creating an arrow extending from level (15, 0.05) to (150, 0.2). The arrow’s fashion, together with width, head dimension, and shade, is personalized for optimum visible influence.
A shaded rectangle, generated utilizing patches.Rectangle and ax.add_patch, is overlaid on the primary plot. This rectangle visually emphasizes a interval from day 0 to day 30, spanning a y-axis vary of -.05 to .05. Its look is outlined by a dashed line, yellow fill, black border, and specified transparency.
A smaller inset plot, created utilizing plt.axes([.25, 1, .2, .5]), gives a magnified view of the preliminary 30 knowledge factors. This inset, positioned relative to the primary determine, is labeled ‘Lag’ and shows each ‘Check’ and ‘Prediction’ knowledge. Axis tick parameters are suppressed utilizing plt.tick_params for visible readability.
In conclusion, this code creates an in depth visualization successfully evaluating check knowledge and predictions. The mixture of the primary plot, the arrow annotation, the highlighted rectangular area, and the zoomed inset plot facilitates a complete evaluation of the mannequin’s efficiency. The exact interpretation of the outcomes, nevertheless, will depend on the context of the check and all_predictions variables, which aren’t outlined inside this code snippet.