Capture click on subplot

Is it possible to capture a click on a of a particular subplot of a figure? (i.e. even if no point is clicked on)? I figure that information is captured somehow, because the plotly toolbar flashes when I do this.

1 Like

This isn’t possible right now. What is your use case?

I was basically intending to have a gallery of plots, where clicking on a plot would select the data in that graph for additional manipulation (and also plot it on a larger graph).

Don’t necessarily need to use subplots for this, I could also make a gallery of individual graphs. But I don’t know the number of graphs until the user loads the data, so I don’t think I’d be able to create the callbacks/links dynamically.

At the very least I can already do this by forcing the user to click on a point in the graph.

In general, one way you can dynamically plot a number of graphs is by populating the children property:

@app.callback(Output('my-div', 'children'), [Input(...)])
def update_content(...):
    return html.Div([
        dcc.Graph(id='graph-1', ...),
        dcc.Graph(id='graph-2', ...),
        dcc.Graph(id='graph-3', ...),

There is an n_clicks property that is available on every dash_html_components element. I wonder if we could use this to wrap a Div and capture generic clicks inside that Div. However, I’m not sure if events will bubble up from inside the Graph to the outer Div or not.

one way you can dynamically plot a number of graphs is by populating the children property:

Yep, I’ve played with this design, but then I lose the ability to define callbacks. I think there was another thread about defining component classes with preset callbacks – that would help here.

Another way is to simply predefine graph-1...graph-N ( or div-1 .. div-N ) for some maximum N, and have them invisible until the data gets in. That feels very inelegant, but maybe it’s a fine practical solution.


I would be interested in this feature (click on a subplot and have it activate a callback).
My use case is a 3x3 grid of subplots in a dcc.Graph. It would be great if the user could click on a particular subplot to ‘zoom in’ (i.e. only that particular subplot would be rendered in the dcc.Graph).

Is this currently feasible in Dash?