Skip to content
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

Add entrypoint for plotting backends #3640

Closed
wants to merge 6 commits into from

Conversation

andersy005
Copy link
Member

@andersy005 andersy005 commented Dec 18, 2019

Libraries, including xarray, register backends via entrypoints. Xarray adds an EntryPoint "group" in its setup.py. Third party libraries add items to that group in their setup.pys.

Xarray and the third-party library don't need to talk to each other directly to register a backend. They talk through pkg_resources.

For instance, hvplot/holoviews would add an EntryPoint for xarray_plotting_backends in its setup.py:

entry_points={"xarray_plotting_backends": ['holoviews = hvplot:plotting']}

and xarray users should be able to achieve what @jsignell proposed in #3553:

import xarray as xr
air = xr.tutorial.open_dataset('air_temperature').load().air
xr.set_options(plotting_backend='holoviews')

air.isel(time=500).plot()
Screen Shot 2019-11-20 at 12 44 26 PM

@dcherian
Copy link
Contributor

EXCITING!

@crusaderky
Copy link
Contributor

if you merge from master you should get all green on the upstream-dev test now

@dcherian
Copy link
Contributor

@andersy005 can you summarize what's needed on the holoviews and xarray side for this to work?

@andersy005
Copy link
Member Author

can you summarize what's needed on the holoviews and xarray side for this to work?

A while back I opened this issue holoviz/hvplot#392. I am about to make modifications to hvplot/holoviews locally to test that this PR is going to work as expected. Once I have a better understanding of what's needed, I will report back.

@andersy005
Copy link
Member Author

After looking at Pandas source code, it's my understanding that

  • Pandas provides a well defined plotting API
  • At runtime, Pandas figures out the right backend to use via _get_plot_backend() and then dispatches the plotting functionality to this backend.

This approach makes interfacing with Pandas objects easy as long as the plotting library adheres to this plotting API. Currently, Xarray's plotting API is closely tied to matplotlib. To support entrypoint for other plotting backend will likely require defining something similar to Pandas's plotting API. Is my interpretation correct?

Pinging @TomAugspurger, @jsignell and @jbednar as they may have ideas on how to proceed with this implementation.

@TomAugspurger
Copy link
Contributor

Is my interpretation correct?

Yep, that's the basic idea. Every call to DataFrame.plot.<kind> begins with a check for the active backend. Based on the configured value, we the correct backend, make the call, and return the result.

@philippjfr
Copy link

@andersy005 Sorry I never followed up here. Trying to get out a new hvPlot release very soon. What's the current status here? @jsignell do you have any comments?

@philippjfr
Copy link

To be clear, I'm just checking whether there's anything that I can or need to do in hvPlot so this can proceed smoothly.

@andersy005
Copy link
Member Author

andersy005 commented Apr 26, 2020

What's the current status here?

I put this PR on a back burner :). As I pointed out in #3640 (comment), it is my understand that xarray will need to define a minimal plotting API for this entrypoint feature to work properly. Would this plotting API be something xarray devs would be willing to have/support? Cc @shoyer @dcherian @jhamman

I could be missing something here. So please let me know if there is another way of getting the entrypoint feature to work without needing to define a plotting API that third-party visualization libraries adheres to.

@andersy005
Copy link
Member Author

Closing this because it has gone stale :(

@andersy005 andersy005 closed this Sep 26, 2021
@TomNicholas
Copy link
Member

TomNicholas commented Sep 26, 2021

it is my understand that xarray will need to define a minimal plotting API for this entrypoint feature to work properly. Would this plotting API be something xarray devs would be willing to have/support?

Do we not want to discuss this in the bi-weekly dev meetings perhaps? (Apologies if it has been and I just missed it.) This seems like a good idea to implement!

@andersy005
Copy link
Member Author

Do we not want to discuss this in the bi-weekly dev meetings perhaps?

👍🏽 I'm in favor of discussing this in the dev meetings... Being able to easily switch plotting backends would be a nice feature to have from a user's perspective.

@jsignell
Copy link
Contributor

I'm sorry I missed pings on this. I am happy to join the dev meeting if that'd be helpful or I can just start paying better attention 🙄

@TomNicholas
Copy link
Member

There is a dev meeting this Wednesday (occurring every fortnight), would be great to see you there!

@andersy005 andersy005 deleted the feature/select_backend branch June 16, 2023 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: Plotting backend options
7 participants