Good Afternoon
Thank you for all your help which is very much appreciated. I am at the final stage of displaying a heatmap within a facetgrid. When I am presenting the data some of the index values may or may not be present for the row / column combination. I would like to display these as blanks and adjust the heatmap entries accordingly. Unfortunately, I cannot get all values (1 to 10) to display on the y axis matching what I have in the heatmap as per below. Any data values not present should display blank rows in the heatmap.
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import re
import numpy as np
waitremap = {'0-2':0,'3-4':1,'5-6':2,'7-8':3,'9-10':4,'11-12':5}
df = pd.DataFrame({ 'Spec':['A','A','A','A','B','B','B','B'],
'Wait':[5,6,2,4,1,2,11,12],
'MyClass':[1,4,7,10,1,2,3,4],
'WaitClass':['5-6','5-6','0-2','3-4','0-2','0-2','11-12','11-12'],
})
heatdf = (pd.crosstab(index=df.MyClass,columns=df.WaitClass,values=df.Wait,aggfunc='count',normalize='index')
#.assign(colnum =1)
.reset_index()
)
heatdf.index = heatdf.MyClass
heatdf1 =(heatdf
.drop(columns=['MyClass'])
)
#g3 = sns.heatmap(heatdf1,cmap='Blues')
g2 = sns.FacetGrid(heatdf1,height=5,sharey=False,sharex=False)
myheatmap = g2.map_dataframe(sns.heatmap)
Any help much appreciated
Thanks
Steven
enter image description here