-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
RFC: feat(python): add plotting backend #13149
Conversation
Great! I don't know much about plotting, but it's incredible to me that we can support it with such a small amount of code. 👍 |
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.
170 lines of code. That's maintainable. :D
|
||
Polars plotting methods are only intended as convenience methods for ease of | ||
use during interactive development. For more complex plots, it is recommended | ||
to use plotting libraries directly. |
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 like this idea. Can we make explicit here that we don't guarantee anything here. It is meant for EDA and we don't want a major version bump if we change anything here.
I wholeheartedly support this initiative 👍
As far as I can tell, this is the Achilles' heel of the approach. There would have to be some standardization effort across plotting libraries to be able to support them as backends. I can already see our issue tracker explode when one of our supported backends changes their API away from whatever we expect. An alternative approach would be to create adapters for various plotting backends, but that would increase our maintenance burden - though it doesn't have to be too bad. If we can get some popular backends to conform to our requirements then I am all in favor of the current approach! |
Thanks all for your feedback, I wasn't expecting such a positive response
It's kinda already happened though, because of pandas, see: https://pandas.pydata.org/pandas-docs/stable/user_guide/visualization.html#plotting-backends So as long these libraries keep supporting pandas, and as long as the Polars signatures are strict subsets of the pandas ones, it should be safe! I'd still like to see a Plotting DataFrame API Standard though, both to future-proof things and to spur more implementations - but I'd still suggest a 2-phase approach:
EDITI've got a 3.5 hour train journey on Sunday to visit relatives, so...maybe that'll be enough time to actually draft out a Plotting DataFrame API Standard and tag relevant people for comments. Will see if I can do this 🤞 I like the idea of bringing so many projects together for such a collaboration 🤝 |
Yes, I can foresee having some indirection to ensure proper mappings |
:toctree: api/ | ||
:template: autosummary/accessor_method.rst | ||
|
||
# DataFrame.plot.line |
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.
this throws
Warning, treated as error:
[autosummary] failed to import polars.DataFrame.plot.line.
Possible hints:
* ImportError:
* ModuleNotFoundError: No module named 'polars.DataFrame'
* AttributeError: 'property' object has no attribute 'line'
make: *** [Makefile:27: html] Error 2
if I uncomment it, can't make sense of why though
I think it can (and probably should!) be made simpler - updated version: #13238 |
closing in favour of #13238, thanks all for your inputs! |
This has been on the back of my mind for several months, finally couldn't ignore it further
The general idea is:
should expect consistent behaviour supported backends. Any extra keyword arguments
you specify are passed directly to the backend itself, and so their behaviour is
backend-dependent.
interactive development.
plot
method which follows a certain standardised signatureThis already exists to some extent thanks to some fantastic work by @datapythonista a few years ago. So, Polars can just "piggy-back" off it, and document the expectations
Timeline
If there's appetite for this, I'd suggest proceeding in a direction that's something like:
scatter
andline
, as they're probably the most used quick plots in interactive developmentbackend
kwarg configurable viapl.Config
plotly
andhvplot
backends?seaborn
andaltair
backends?plot
function?Demo
Where's matplotlib?
matplotlib is the default plotting backend in pandas.plotting, so they never implemented the top-level
plot
function. So, Polars can't (yet) use them as a plotting backend. But, if we define the rules and expectations, then a matplotlib-backed backend should be feasible, if they were interested! Either way, to re-iterate - no plotting code, whether matplotlib or anything else, would live in Polars itselfNecessary precursors
The following would need to go in first:
Nice to have precursors
So, there's time to update this and make it mergeable, just wanted to start getting feedback. Looks like people are generally supportive anyway, thanks!