Skip to content

Possibility of using Matplotlib by importing Polars library in Python #25317

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

Closed
Killpit opened this issue Feb 24, 2023 · 3 comments
Closed

Possibility of using Matplotlib by importing Polars library in Python #25317

Killpit opened this issue Feb 24, 2023 · 3 comments

Comments

@Killpit
Copy link

Killpit commented Feb 24, 2023

Problem

Polars is one of the recent Python library that has all the functionalities in Pandas while being much faster. However, as I looked at the documentation from both Polars library and matplotlib, I couldn't find anything.

If polars library support is added to matplotlib, it becomes much easier and faster to create visualisations without losing time and the data frame becomes much tidier.

Proposed solution

The solution should allow a support for Polars library where an extra line _polars to visualisation so that we can use Polars data frames

@jklymak
Copy link
Member

jklymak commented Feb 24, 2023

We don't officially support pandas, so I doubt we are officially going to support polars. However if polars data frames behave properly when using no.asarray then they should work the same as pandas data frames in our methods. Did you test to see if they work?

If you mean df.plot type methods that is totally in pandas court, but if they go that route they should come talk to us.

@tacaswell
Copy link
Member

This is the sort of integration that https://github.com/matplotlib/data-prototype is trying to make easier by pushing the integration point out a level from the core library.

In the current state of Matplotlib, we need things as numpy arrays (and will do that conversion internally via np.asarray as Jody said) because at the bottom we need to actually have all of the array data materialized in our code. If polars supports this it should "just work" and if not, I think that the work needs to happen in polars to support that as it is very very unlikely that we are going to thread a polars dependency through the entire code base.

I am going to close this and track this work in #16402 and #22645 .

@jklymak
Copy link
Member

jklymak commented Feb 24, 2023

Polars works fine so far as I can tell, at least for a simple dataframe. Again, if you want df.plot() that is something to request of polars.

import matplotlib.pyplot as plt
import polars as pl

data = {"a": [1, 2, 3, 4], "b": [3, 4, 5, 6]}
df = pl.DataFrame(data)

plt.plot(df['a'], df['b'])
plt.show()

@QuLogic QuLogic added Community support Users in need of help. and removed New feature labels Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants