-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
initial build-out of facet wrapping #1838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@nicolaskruchten
nicolaskruchten
commented
Oct 21, 2019
- Closes Facet wrapping plotly_express#2
- Closes Passing data frame column to facet_col raises exception #1836
nicolaskruchten
commented
Oct 21, 2019
The Percy diffs are because this code generates x domains that range from 0-1 instead of master which goes from 0-0.98. 0-1 seems "more correct" to me... @jonmmease any insight into why the previous version does what it does?
nicolaskruchten
commented
Oct 21, 2019
Ah I found it: https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/subplots.py#L529
Basically I'm now passing a length-0 element to row_titles in single-facet cases, not [None] and so it skips this line.
OK so I'm fine with these Percy diffs. Ready for review!
I guess I need some tests.
emmanuelle
commented
Oct 22, 2019
It was not introduced by this PR, but the behaviour when there is a very large number of cols/rows is weird. For example
px.scatter(gapminder, x="pop", y="lifeExp", facet_row="country")
or
px.scatter(gapminder, x="pop", y="lifeExp", facet_col="country", facet_col_wrap=8)
give errors like
~/code/plotly.py/packages/python/plotly/_plotly_utils/basevalidators.py in raise_invalid_val(self, v, inds)
281 typ=type_str(v),
282 v=repr(v),
--> 283 valid_clr_desc=self.description(),
284 )
285 )
ValueError:
Invalid value of type 'builtins.float' received for the 'domain[1]' property of layout.yaxis
Received value: -0.010555555555555565
The 'domain[1]' property is a number and may be specified as:
- An int or float in the interval [0, 1]
which is not very helpful as an error message. Should we either introduce a limit in the number of cols/rows, or try to catch this and output a better message?
emmanuelle
commented
Oct 22, 2019
Thank you for fixing the bug of #1836.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say "number of columns. Facets are wrapped at this number to span multiple rows". Maybe it's just me, but since I'm not familiar with this kind of representation I had a hard time understanding what this was before I actually tried it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
emmanuelle
commented
Oct 22, 2019
ok, I just left a doc suggestion which you might or might not implement. My comment about the large number of cols/rows is not specific to this PR and can go to an issue. 💃
81e1de4 to
be875be
Compare
nicolaskruchten
commented
Oct 22, 2019
Nice catch on the "many columns" thing, here's the issue I broke it off into: #1839
nicolaskruchten
commented
Oct 22, 2019
OK I've added percy tests for the two tricky cases of facet wrapping, and a test locking down the fix for #1836
nicolaskruchten
commented
Oct 22, 2019
The plotlyjs_dev_build test failure looks like something which will go away the next time there's a master commit on plotly.js