I'm new to python and am trying to create a heatmap within a heatmap - in other words, use one matrix as the foundational matrix and show which combinations are present or missing in smaller dataframes.
Here is an example using some random numbers:
np.random.seed(7)
data = {'a':[1,2,3,4,5,6,7,8,9,10],
'b':[1,2,3,4,5,6,7,8,9,10]}
df = pd.DataFrame(data)
#This is the master matrix that has all values
df_2 = pd.DataFrame(np.random.randint(10, size = 100))
#This is the df from which I draw median/mean/etc
matrix = pd.crosstab(df['a'], df['b'], values=df_2, aggfunc='median')
sns.heatmap(matrix) #This is the generated heatmap; note it is 10 by 10
The problem happens when I try to take only certain values from df_2; my heatmap shrinks and I don't see all values.
a = df_2[df_2 > 7]
matrix_2 = pd.crosstab(df['a'], df['b'], values=a, aggfunc='median')
sns.heatmap(matrix_2) #Resulting matrix is now 3 by 3.
How can I make the resulting 4 by 4 matrix appear on the master matrix, i.e., showing all the missing values ?
Any help would be greatly appreciated!