July 2019
Beginner to intermediate
740 pages
16h 52m
English
We will often find the need to annotate specific points in our visualizations either to point out events, such as the days on which Facebook's stock price dropped due to certain news stories breaking or labeling values that are important for comparisons. For example, let's use the plt.annotate() function to label the support and resistance:
>>> ax = fb.close.plot(title='FB Closing Price 2018', figsize=(15, 3))>>> ax.axhspan(support, resistance, alpha=0.2)>>> plt.annotate(... f'support\n(${support:,.2f})',... xy=('2018-12-31', support),... xytext=('2019-01-21', support),... arrowprops={'arrowstyle' : '->'}... )>>> plt.annotate(... f'resistance\n(${resistance:,.2f})',... xy=('2018-12-23', resistance)... )>>> plt.ylabel('price ($)') ...Read now
Unlock full access