July 2019
Beginner to intermediate
740 pages
16h 52m
English
As promised, let's learn an easier way to generate heatmaps compared to what we had to do in Chapter 5, Visualizing Data with Pandas and Matplotlib. Once again, we will make a heatmap of the correlations between the OHLC stock prices, the log of volume traded, and the daily difference between the highest and lowest prices (max_abs_change); however, this time, we will use seaborn, which gives us the heatmap() function for an easier way to produce this visualization:
>>> sns.heatmap(... fb.sort_index().assign(... volume=np.log(fb.volume), ... max_abs_change=fb.high - fb.low... ).corr(), ... annot=True, center=0... )
We also pass center=0 so that seaborn puts values of 0 (no correlation) at the center of the colormap ...
Read now
Unlock full access