Heatmap clickData


I have a heatmap made using plotly.graph_objects.Heatmap. I’m now designing a dash app, which should have the heatmap and a separate text box or graph displaying some data associated with a given heatmap cell. I would like the text box/graph to update based on which cell was last clicked by the user.

Can someone tell me how to access the ‘clicked cell data’ for a given heatmap cell? I think the equivalent for a graph (which I’ve seen mentioned elsewhere in answers to similar questions) is dcc.Graph.clickData, but I can’t see a clickData attribute for go.heatmap.

Thanks! Tim

Welcome back, Tim!

The clickData attribute belongs to the dcc.Graph component, not the Graph object. It’s a bit confusing since they share a similar name, but there’s an important difference:

  • dcc.Graph is a Dash Core Component and is used to render a Graph object
  • A Graph object is the figure itself, e.g. your Heatmap

The clickData attribute that you mentioned does not belong to the Graph object, but the dcc.Graph component. So every Graph object that you render inside a dcc.Graph component has it!

Here’s the official documentation for Interactive Graphing:


Excellent! Thanks for your help with this, that’s an important point to be aware of.