How do I make the lasso selection of a plotly express scatter_matrix additive?

81 Views Asked by At

It is very easy to create a scatter_matrix using plotly express:

import plotly.express as px
df = px.data.iris()
fig = px.scatter_matrix(df,
    dimensions=df.columns[0:4],
    color=df.columns[4])
fig.update_layout(
    autosize=False,
    width=1200,
    height=1200,
)
fig.show()

Highlighting a subset of the data using the lasso or rectangular selection tool even highlights the corresponding points in the other graphs.

However, when marking points in two plots I would prefer that not the union of those are highlighted but the intersection. In the example image below this would mean that only a few red and green points are still visible/highlighted, but no blue points.

What can I do in order to achieve that?

scatter_matrix with two selection

One bonus question: Is there a way to make it faster and more reactive, like with scattergl for regualar scatter plots? One more bonus question: Is there a way to do this in R instead of python? In case the answer is a bit more complicated, I could ask this as a seperate question.

0

There are 0 best solutions below