question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pandas plotting backend?

See original GitHub issue

Plotly has toplevel .plot function which allows for a pandas plotting backend to exist:

https://github.com/plotly/plotly.py/blob/4363c51448cda178463277ff3c12becf35dbd3b8/packages/python/plotly/plotly/__init__.py

Like this, if people have plotly installed, they can do:

pd.set_option('plotting.backend', 'plotly')

and then df.plot.line(x=x, y=y) will defer to plotly.express.line(data_frame=df, x=x, y=y):

image

It’d be nice to be able to do

pd.set_option('plotting.backend', 'seaborn')

and then have df.plot.line(x=x, y=y) defer to seaborn.line(data=df, x=x, y=y)

Would you be open to these ~150 lines of code or so to allow seaborn to be set as a plotting backend in pandas? Check the link above to see what it looks like in plotly. I’d be happy to implement this, just checking if it’d be welcome

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolaskruchtencommented, Dec 6, 2022

In fairness, though, the plotly layer is light in part because a lot of stuff just doesn’t work.

Oh yes, the plotly backend deliberately does not aim to be arg-compatible with the builtin backend! This is what I put in the docs:

image
1reaction
mwaskomcommented, Dec 6, 2022

I wouldn’t ask seaborn to add any new plots (like pie) - if it’s not in seaborn, I’d argue that it probably shouldn’t be in pandas either

That’s tricky because sometimes things aren’t in seaborn because they’re in pandas, e.g. “area plots” https://github.com/mwaskom/seaborn/issues/2410. In cases where a “seaborn version” of a plot type wouldn’t add anything beyond what an existing pandas (or matplotlib) implementation can do, I’m usually reluctant to add it, especially if it doesn’t fit nicely into seaborn’s existing plot taxonomy. It’s hard to see a case for pandas fully deprecating area and (alas) pie charts — they’re fundamental for the kinds of applications that many people use pandas for.

The layer in seaborn should really be very light, just like it is in plotly

In fairness, though, the plotly layer is light in part because a lot of stuff just doesn’t work. e.g. for a few quick things i tried, both wide data and subplots raise. And in the example you linked to above, the by and bins (bins!!) parameters for histograms are simply ignored, as with s and c for scatter. I suppose it’s fine for the plotly backend to not be feature-complete with the matplotlib backend, but you’d be talking about deprecation of major functionality if you took the same approach and didn’t include anything in the “seaborn” backend that wasn’t a simple parameter name translation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pandas plotting backend in Python
The Plotly plotting backend for Pandas is a more convenient way to invoke certain Plotly Express functions by chaining a .plot() call without...
Read more >
python - Change pandas plotting backend to get interactive ...
You need pandas >= 0.25 to change the plotting backend of pandas. The available plotting backends are: matplotlib · hvplot >= 0.5.1
Read more >
pandas.DataFrame.plot — pandas 1.5.2 documentation
Make plots of Series or DataFrame. Uses the backend specified by the option plotting.backend . By default, matplotlib is used. Parameters.
Read more >
Plotting in Pandas Just Got Prettier - Towards Data Science
Bokeh backend. Bokeh is another Python plotting library that provides rich and interactive visualisations. The visualisations can be viewed in a ...
Read more >
Bokeh Plotting Backend for Pandas and GeoPandas - GitHub
Pandas -Bokeh provides a Bokeh plotting backend for Pandas, GeoPandas and Pyspark DataFrames, similar to the already existing Visualization feature of Pandas ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found