A heatmap is a graphical representation where individual values of a matrix are represented as colors. A heatmap is very useful in visualizing the concentration of values between two dimensions of a matrix. This helps in finding patterns and gives a perspective of depth.
Let's start off by creating a basic heatmap between two dimensions. We'll create a 10 x 6 matrix of random values and visualize it as a heatmap:
>>> # Generate Data >>> data = np.random.rand(10,6) >>> rows = list('ZYXWVUTSRQ') #Ylabel >>> columns = list('ABCDEF') #Xlabel >>> #Basic Heat Map plot >>> plt.pcolor(data) >>> plt.show()
After the preceding code is executed we'll get the following output:
In the preceding code, we used the pcolor()
function to create the heatmap colors. We'll now add labels to the heatmap:
>>> # Add Row/Column Labels >>> plt.pcolor(data) >>> plt.xticks(np.arange(0,6)+0.5,columns) >>> plt...