Plotly Heatmap Axis

How do i set numbers in my axis as categories in my heatmap. Doc does not have an ‘xaxis_type’ object in the layout? How can i specify my axis type

Hi @Jason4,

I’m not sure what are you referring to.

This heatmap

fig =  go.Figure(go.Heatmap(x= ['1', '2', '3', '4', '5'],
                            y= ['L', 'M', 'N', 'O', 'P'],
                            z=z, colorscale='matter'))
fig.update_layout(width=500, height=500)

has categorical axes.

If you are interested in another case, please be more explicit.

@empet. I am using an array from a dataframe with numbers but i guess i have to convert them to a list of strings as per your example.

@empet. Need a solution in this. SO my idealogy is to build a heatmap on a picture image which shall highlight points on this image depending on my data filter. So my data filter will change causing my axis length to change (increasing or decreasing), causing the information to be distributed in appropraiately. So my idea is to build the heatmap to be highlited depending on the values from my data. How can i work around having a stable axis which does not change and only the colors from the heatmap change from region to region on the image background?
Hope you understand my idealogy.

In my code above, z was defined as np.random.randint(2,16, (5,5)), i.e. it is a numerical array. Only xaxis, yaxis ticklabels are strings.

I cannot understand what are you saying in the last message.

Is the following suggestion what you need?

If your image has the resolution 128 x128, define a heatmap of maximal size, initially with nan z-values.
`z = np.nan*np.ones((128,128))

Update some values in this z array at each step of your simulation and display the corresponding heatmap with gaps.

@empet sent you a screenshot.

Hi @empet. Could you please illustrate your suggestion with an example so i can follow through. Seems to be the best solution for me. Do i initialize with nan and then append z values as my z values update?
For say 5 x 5 grid for example