jupyter-widgets-contrib / ipycanvas

Interactive Canvas in Jupyter
https://ipycanvas.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
688 stars 64 forks source link

Matplotlib renderer? #179

Open bdch1234 opened 3 years ago

bdch1234 commented 3 years ago

I was just wondering if you had any plans on implementing an mpl-renderer with ipycanvas at some point? Perhaps also integrate in Ipympl in that case?

If not, then perhaps a scope for Kaleido?

martinRenou commented 3 years ago

I wouldn't say that it's a plan, more of an idea for a fun project that I had at some point. I might never take the time to do it, unless the motivation strikes me at some point.

The thing is I am wondering if it's really worth the work? ipympl is fairly fast already, I am not sure ipycanvas would be faster at rendering. But it would surely be fun to do!

If not, then perhaps a scope for Kaleido?

I am not familiar with the plotly internals. It looks to me at first glance that Kaleido is really just the front-end library that does the rendering for plotly? Is there a Python "canvas" API in plotly?

martinRenou commented 3 years ago

One advantage compared to ipympl would be that an ipycanvas renderer would be written entirely in Python :) Making contributions a lot easier.

bdch1234 commented 3 years ago

Understood, thanks for providing more color on that.

I am not familiar with the plotly internals. It looks to me at first glance that Kaleido is really just the front-end library that does the rendering for plotly? Is there a Python "canvas" API in plotly?

Don't know about a canvas-api for Plotly, perhaps in the JS-lib (which is the renderering part) but I wouldn't know. Kaleido is however meant to be plotting-lib agnostic. It is basically provides a way to produce static images from web-based plotting-libs without having to use something like Selenium, and which is fast. From what I understand, they are able to do that by compiling their own Chromium-based exe, where they only include the parts they need. But maybe that is better suited for something like bqplot?

martinRenou commented 3 years ago

But maybe that is better suited for something like bqplot?

Well, bqplot is definitely powerful, and you can do low-level stuff with it. Although I don't think it is very well suited for this purpose. My guess is that it would be the same for plotly.

Concerning the idea to make an ipycanvas renderer, I feel like it would be very similar to the cairo backend, as cairo and ipycanvas share very close APIs.

martinRenou commented 3 years ago

If you don't mind, I'd like to keep this issue open :) I think it's a great idea and would like to keep a place to discuss it.

bdch1234 commented 3 years ago

Absolutely, I guess I did get a little trigger-happy when closing down old issues ;)