-
wbdata 5
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
Lecture1.4
-
Lecture1.5
-
-
Hexbin Plots 7
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
Lecture2.5
-
Lecture2.6
-
Lecture2.7
-
-
Heatmap 5
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
Lecture3.4
-
Lecture3.5
-
-
Boxplot 2
-
Lecture4.1
-
Lecture4.2
-
-
Violin Plot 5
-
Lecture5.1
-
Lecture5.2
-
Lecture5.3
-
Lecture5.4
-
Lecture5.5
-
-
Time Series 2
-
Lecture6.1
-
Lecture6.2
-
-
Pairplot 2
-
Lecture7.1
-
Lecture7.2
-
-
Kernel Density Estimation 3
-
Lecture8.1
-
Lecture8.2
-
Lecture8.3
-
Correlation Heatmap
In computer science, 0 is False and 1 is True. If we set the parameter dtype to Bool in np.zeros() we can get back False instead of 0.
import numpy as np
np.zeros(corr.shape, dtype=bool)
Now, this is where it gets complicated. np.triu_indices() returns two arrays of x and y coordinates where the coordinate combinations are the upper right triangle coordinates.
mask = np.zeros(corr.shape, dtype=bool)
np.triu_indices(len(mask))
We give a measure of number of rows, and we get back the coordinates for a square matrix with row and column size of this argument. We also set the array of true falses as a variable mask.
Now that we know how to get the correct parts of the array, we can set them to be true.
mask[np.triu_indices(len(mask))] = True
mask
Finally, use the argument mask to apply our mask!
sns.heatmap(corr,annot=True,mask=mask)
plt.show()
Source Code
Prev
Heatmap
Next
Introduction