plotly_express icon indicating copy to clipboard operation
plotly_express copied to clipboard

SPLOM diagonals

Open nicolaskruchten opened this issue 5 years ago • 18 comments

from https://community.plot.ly/t/plotly-express-scatterplot-matrix-diagonal/21464

Is it somehow possible to set the diagonal of the scatterplot matrix in plotly express to a histogram like in pandas? And even more better like seaborns pairgrid a stack histogram with its argument hue? Would be really nice.

nicolaskruchten avatar Apr 03 '19 13:04 nicolaskruchten

Would love this to be built in at the plotly.js level. From https://github.com/plotly/plotly.js/issues/2555:

Things we could do, but would require some thought

  • Add sub-trace on the diagonal (e.g. with diagonal.mode: 'scattergl' || 'histogram' || 'box' || 'violin', see #2505 (comment)

alexcjohnson avatar Apr 03 '19 14:04 alexcjohnson

Yeah we definitely need this baked in at the JS level! I'd want brushing to match, meaning if I lasso-select some points, I'd see "part of" the diagonal being selected somehow. Easy with histograms (just shade part of the bar) but harded with box/violin.

I'd also love to be able to have contours in the upper triangle and points in the lower triangle, or something like that. Brushing in that case seems very challenging though:

image

nicolaskruchten avatar Apr 03 '19 14:04 nicolaskruchten

Ah yeah, contours on one triangle would be cool! One easy way to handle brushing in that case would be to just use the coordinates of the outline to select the corresponding points as though the display was scatter. On the diagonal I guess brushing should be limited to 1D regardless of the display mode.

alexcjohnson avatar Apr 03 '19 15:04 alexcjohnson

Oh no I mean the other way: if you select some blob-shaped assortment of points in a scatter subplot, how do you render the contours/histogram/boxes?

nicolaskruchten avatar Apr 03 '19 15:04 nicolaskruchten

Ah I see. For all the diagonal options I feel like we can make a separate "filtered" trace - so a second histogram inside the first, a separate violin/box next to the first.

Definitely tricky for contours though... it's hard to make two overlaid contour plots useful. So either we just plot contours of the selected data, or perhaps faded black & white contours of the full data set with semi-transparent contours in color on top of it, kind of like parcoords

alexcjohnson avatar Apr 03 '19 16:04 alexcjohnson

Something like that, yep

nicolaskruchten avatar Apr 03 '19 18:04 nicolaskruchten

This would be really neat, is anything like this planned?

wlievens avatar Sep 23 '19 12:09 wlievens

Is this not possible with graph_objects.Splom?

grisaitis avatar Oct 17 '19 20:10 grisaitis

@grisaitis not yet! Plotly Express uses graph_objects.Splom under the hood so if it were possible there we'd have it in PX as well already :)

nicolaskruchten avatar Oct 18 '19 00:10 nicolaskruchten

Ok so the roadblock is that the main dependency doesn't support this. Do we know of an open issue in plotly/plotly about this?

grisaitis avatar Oct 22 '19 21:10 grisaitis

Yep: https://github.com/plotly/plotly.js/issues/2555

nicolaskruchten avatar Oct 22 '19 21:10 nicolaskruchten

Any news on this? Coming from a data science background, this seems like a very common plot that would be super useful for EDA!

ChristianMichelsen avatar Feb 12 '21 09:02 ChristianMichelsen

Bump for histograms on the diagonals

InCogNiTo124 avatar Jan 05 '22 14:01 InCogNiTo124

👍 Would love to see this too!

dragoljub avatar Feb 16 '22 17:02 dragoljub

@nicolaskruchten - I really like your suggestion. Would be very nice to have this as a feature.

rsgoodwin avatar May 29 '22 20:05 rsgoodwin

Hi all,

This would be wunderful to have in Plotly express. Charts like this are really workhorse when presenting classification algorithms.

Seaborn has similar algo implemented https://seaborn.pydata.org/examples/scatterplot_matrix.html . It is kind of shame for Plotly not to have sth like that already implemented.

I saw similar implementation in figure factory, but ff seems not to be maintained anymore, correct me if I am wrong?

milanzmitrovic avatar Jul 11 '22 22:07 milanzmitrovic

Is there any update on this?

UpstatePedro avatar Feb 01 '23 13:02 UpstatePedro

While not using px it is possible with the figure factory, as a workaround until this is added to px: ff.create_scatterplotmatrix

using the diag='histogram' option.

hughjward avatar Feb 24 '23 11:02 hughjward