Load/Show data in subplot after clicking bar in a barchart

Hi Everyone,
I try to create a barchart, with a subplot(scatterplot) below. At first the subplot should be empty.
For each button that gets clicked the subplot should get filled with a new trace of data corresponding to the clicked bar.

Can anyone help me how this could be achieved?

Thanks in advance :slight_smile:

Something like:

Plotly.newPlot(/* if of your graph div */, [])

function addTrace() {
  Plotly.addTraces(/* if of your graph div */, [{
     /* your new trace */
  ])
}

More info on Plotly.addTraces here: https://plot.ly/javascript/plotlyjs-function-reference/#plotlyaddtraces