HEAT MAPS IN MATPLOTLIB
Listing 5.22 displays the content of heatmap1.py that illustrates how to render a heat map in Matplotlib.
LISTING 5.22: heatmap1.py
import numpy as np data = np.random.random((16, 16)) plt.imshow(data, cmap='tab20_r', interpolation='nearest') plt.show()
Listing 5.22 contains an import statement, followed by the variable data that is initialized as a 16x16 matrix of random values. The next code snippet renders the heat map, and the final code snippet displays the heatmap. Launch the code in Listing 5.22, and you will see the image that is shown in Figure 5.19.

FIGURE 5.19 A heat map generated by the code in Listing 5.22