Is it possible to do a scatter matrix plot with Plotly in which the color shows the density like this (not Plotly)?

I would like to have the functionality of the `px.scatter_matrix`

function, i.e. that the axes are shared, and also a similar interface if possible. I cannot find such thing.

If it is not a scatter plot with individual points but a collection of 2D histograms that would also work.

Just in case anyone else comes here from Google interested in the â€ścolor showing densityâ€ť part:

```
import numpy as np
from scipy import stats
import plotly.express as px
def get_density(x:np.ndarray, y:np.ndarray):
"""Get kernal density estimate for each (x, y) point."""
values = np.vstack([x, y])
kernel = stats.gaussian_kde(values)
density = kernel(values)
return density
# generate some interesting data
def measure(n):
"Measurement model, return two coupled measurements."
m1 = np.random.normal(size=n)
m2 = np.random.normal(scale=0.5, size=n)
return m1+m2, m1-m2
m1, m2 = measure(2000)
d = get_density(m1, m2)
fig = px.scatter(x=m1, y=m2, color=d, )
fig.show()
```

1 Like