The same question as a heatmap- like graph, but for categorical variables , but using Python and seaborn instead of R:
Imagine that I have the following data frame:
df = pd.DataFrame({"John":"No Yes Maybe".split(), "Elly":"Yes Yes Yes".split(), "George":"No Maybe No".split()}, index="Mon Tue Wed".split())
Now I would like to build a heat map and color each cell in accordance with its value. That is, "Yes", "No", "Maybe", for example, becomes "Green", "Gray", "Yellow". A legend must have these three colors and corresponding meanings.
I myself solved this problem as follows. It seems that I canโt pass the categorical color map to the heat map of the sea wolf, so instead I replace the entire text with numbers and subsequently recreate the color map used by the seaweed inside the country, i.e.
import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import numpy as np import matplotlib.patches as mpatches

My question is: is there a shorter way to compile this heatmap? Otherwise, it may be a function that is worth implementing, in which case I will publish it on the seaborn tracker.
inodb source share