plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
16k stars 2.53k forks source link

enable non-cartesian facets in Plotly Express: polar, ternary, maps etc #2646

Open nicolaskruchten opened 4 years ago

nicolaskruchten commented 4 years ago

Today PX only supports faceting for 2d-cartesian functions, but it should support faceting for all functions, in principle.

inkychris commented 3 years ago

I'd like to work on this if it's still not on any internal roadmap? I see you pointed to this bit of code. Presumably the px API would also need expanding to accept the facet_* arguments too? Are there any other things that I should be aware of if I were to take this on?

nicolaskruchten commented 3 years ago

Hi @inkychris ! No one is working on this at the moment so if you want to take it on, I'd love to accept a PR :)

I actually activated this for geo subplots in this PR https://github.com/plotly/plotly.py/pull/2923/files (although I apologize, I did it alongside a bunch of other changes).

In principle, it's as easy as just adding the facet_* kwargs in the _chart_types.py file, and everything else should "just work" but the challenge with subplot types like polar, ternary etc is that their tick labels are less well-behaved than the cartesian subplots, so they overlap. This means that some trial-and-error tuning of the default row and col facet spacings will be necessary.

inkychris commented 3 years ago

Okay cool. I haven't explored the code base yet but is this/does this need to be covered by unit tests or should it just be a case of tuning things until it looks okay and getting you/someone to verify it?

nicolaskruchten commented 3 years ago

Hehe, well, I'm not proud to notice that my PR didn't have any tests, so clearly at the time I didn't feel that worried about it. Let's get things looking OK and then I'll see if anything warrants some tests. If so, they'll probably need to be fairly generic ones that I can write ;)

inkychris commented 3 years ago

Do you agree that polar plots should end up with the same scaling by default? If not then that makes things a bit simpler!

nicolaskruchten commented 3 years ago

I'm not sure I understand the question... what does "same scaling" mean in this case?

inkychris commented 3 years ago

Polar graphs scale to fit the data so the axes aren't the same for each facet by default like they are with scatter plots.

nicolaskruchten commented 3 years ago

Oh I see. This one is a bit tricky... for cartesian we added special Plotly.js handling to "match" axes, and in principle someday we'll do the same for polar, ternary and all the others, so I don't think that PX should do this. This will make the experience of making faceted polar charts less nice, because users will have to explicitly force the ranges to match via .update_polars(...) if that's what they want, but I think it's the right call, and the easier one to implement, yes :)

mich119 commented 1 year ago

Hey,

Any update on the facets in PX maps?

Kind regards