I'm using the heatmap in seaborn (sns.heatmap) to show a matrix of binary values true/false. It works just fine but the color bar as expected is showing a range of values from 0-1 (when in reality there are only two colors).
Is there any way to change this to a legend showing the true/false colors? I couldn't find anything in the documentation
https://seaborn.pydata.org/generated/seaborn.heatmap.html
Example:
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
df = pd.DataFrame({'a':[False,True,False,True,True,True],
'b':[False,False,False,False,True,False],
'c':[False,True,True,False,True,True],
'd':[False,True,False,True,True,True],
'e':[False,True,True,False,False,True],
'f':[False,True,False,False,True,True]})
# Set up the matplotlib figure
f, ax = plt.subplots(figsize=(13, 13))
# Generate a custom diverging colormap
cmap = sns.diverging_palette(300, 180, as_cmap=True)
# Draw the heatmap with the mask and correct aspect ratio
_ = sns.heatmap(df, cmap=cmap, center=0, square=True, linewidths=.5, cbar_kws={"shrink": .5})