Check if points are inside pre-defined selections area

I’m trying to check if the points in the chart are contained in predefined selections, so I’ve add a selection box with the proper configuration of the layout section:

var N = 100;

function randomArray() {
  var output = new Array(N);
  for (var i = 0; i < N; i++) {
    output[i] = Math.random();
  return output;

var myPlot = document.getElementById("plotly-graph");

var settings = [
    mode: "markers",
    x: randomArray(),
    y: randomArray()

var layout = {
  selections: [
      type: "rect",
      x0: 0.1,
      x1: 0.2,
      xref: "x",
      y0: 0.1,
      y1: 0.2,
      yref: "y"

var config = {};

Plotly.react(myPlot, settings, layout, config);

The problem is that the array of selected points is empty until I manually add another selection (using manual interaction with the selection tool from the taskbar).
After that, the points within all selections are correctly included in the array of selected points.
I would like to find a way to trigger this selection event programmatically, without having to use a manual interaction, is this possible? Any suggestions on how to solve this problem?

Thank you!

No one can help me on this topic?

You can access an arrangement of the selected points in myPlot._fullData[0].selectedpoints

Plotly.newPlot(myPlot, settings, layout).then( _ => {
  • selectedpoints
    Parent: data[type=scatter]
    Type: number or categorical coordinate stringArray containing integer indices of selected points. Has an effect only for traces that support selections. Note that an empty array means an empty selection where the unselected are turned on for all points, whereas, any other non-array values means no selection all where the selected and unselected styles have no effect.