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

"Shift" values in heatmap


I would like to have a heatmap that does not “start” at the top left corner. I would like to insert some empty values first so the real data begins the third or fourth column. I already tried inserting an empty string and numpy.nan but with no sucess (Error in the Dash webview). When I insert 0 or -1, the values are displayed in the color of the very low values which is not what I want.

Another option would be to specifiy some particular color (e.g. White) for some specific value that does not occur in my dataset naturally (e.g. -1) so I can use this value as a placeholder.

Maybe someone already had this issue before.

Thanks in advance, Lorenz


Here is an example that defines a heatmap as you intended. I think that you defined the heatmap only giving its z-values, but to get gaps in the upper left corner you should give x and y, too:

x= np.linspace(0, 1, 10)
y= np.linspace(0, 1, 10)
z= np.random.randint(4,11, size=(10,10)).astype(float)

z[:, :2] = np.nan
z[-2:, :] = np.nan

fig = go.Figure(go.Heatmap(x=x, y=y, z=z, colorscale='matter'))
fig.update_layout(width=500, height=500)