Black Lives Matter. Please consider donating to Black Girls Code today.

Heatmap by value instead of dataframe size?

Hi All,

Is it possible to create a heatmap based on the values in a dataframe rather than the size? Can’t seem to find any documentation that covers this. Thanks!

Hi @jrotta,

You can define a heatmap whose z-values are read from a daframe column, but its values must be reshaped to a 2d array. Something like this:

df = pd.DataFrame({'z': np.random.randint(2,13, 300).astype(float)})
fig = go.Figure(go.Heatmap( z=df['z'].values.reshape((20,15)), colorscale='matter'))