Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Facet wrapping #2

Closed
nicolaskruchten opened this issue Mar 11, 2019 · 11 comments · Fixed by plotly/plotly.py#1838
Closed

Facet wrapping #2

nicolaskruchten opened this issue Mar 11, 2019 · 11 comments · Fixed by plotly/plotly.py#1838

Comments

@nicolaskruchten
Copy link
Contributor

No description provided.

@kmader
Copy link
Contributor

kmader commented Apr 16, 2019

Definitely interested in this feature, also having different scales for different facets. I didn't immediately see how to do this.

@nicolaskruchten
Copy link
Contributor Author

Indeed, we don't have a free-scales feature at the moment, but we can look at adding it when we add facet-wrapping.

@sakethsaxena
Copy link

Hey!
I recently started using plotly express, just wondering if there is any momentum on this feature yet?

I was trying to generate a facetted scatter plot using a single dimension/column which has about 80-90 unique entries using facet_col in px.scatter() but it throws a value error.

@joelostblom
Copy link

I am also very interested in having the equivalent of seaborn's col_wrap parameter. In the meantime, is there any workaround for achieving this behavior with plotly express? I regularly need to plot > 10 subplots and don't have another variable to use for row facetting.

@chriddyp
Copy link
Member

Could you introduce a new column("row_number") into your data frame that would be used to break apart into rows?

@joelostblom
Copy link

@chriddyp Thanks for the suggestion, that would work around the problem for my own visualization needs.

One of the reasons I am interested in plotly express is for teaching people new to programmatic data visualization. For this purpose it would be great if there is a wrapping parameter, since that would be easier to understand.

@nicolaskruchten
Copy link
Contributor Author

@chriddyp's workaround is the best way forward right now, and we're very keen to add this to our library... Pull requests are welcome, of course, if someone wants to give it a shot before we get around to it :)

The API I would aim for is basically the same as Seaborn's, and the modifications would be in https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/express/_core.py (basically wherever facet_row or facet_col is referenced we'd need an if block to handle the wrapping case).

We could also think about synthesizing a "row number" into the data frame higher up in the pipeline and reusing the existing logic.

@joelostblom
Copy link

Hmm, maybe I misunderstood the proposed workaround initially... I just tried adding row numbers to simulate col_wrap=3 and ended up with the plot below:

image

Initially, I thought that empty columns would be removed and wrapped around like in this mockup:

image

The current plotly express behavior makes more sense than what I was thinking, but I am suspecting this means I misunderstood what you meant when you proposed the workaround @chriddyp and @nicolaskruchten. In this example, how would you add row numbers to the "Sun, Sat, Thur, and Fri" observations to achieve the desired wrap around behavior?

@nicolaskruchten
Copy link
Contributor Author

Yeah... This is going to be a pretty rough workaround until we implement this for real: you'd have to provide your own row and column, and on top of that you wouldn't get per-subplot titles, you'd be stuck with the per-column and per-row "row_number=1" type labelling, unless you added your own annotations.

@nicolaskruchten
Copy link
Contributor Author

OK, I've got a working version of PX with a new facet_num_cols kwarg that results in this (and is incompatible with facet_row and marginal*... should be in the next version of plotly! Thanks for the nudge :)

image

@joelostblom
Copy link

Beautiful! Thanks for your responsiveness!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants