Altair: Compatibility with / export to Matplotlib

Created on 2 Nov 2016  Â·  10Comments  Â·  Source: altair-viz/altair

This is a super promising library and I really like the simplified syntax for making basic chart types. However, a big bottleneck for me is that I still rely heavily on matplotlib for making final figures etc. I don't see that changing any time soon so I wonder if any thought has been put into connecting Altair with Matplotlib. Are there any plans in the works to create MPL figures etc using the vega-style specification? Or exporting Altair figures to matplotlib objects?

Perhaps this is also relevant to bring up on the MPL repo as well, but more generally would this be a long-term high-effort project, or something more doable in the short term?

enhancement

Most helpful comment

Note that the 2018 John Hunter Fellowship will support work on a matplotlib renderer for Altair/Vega-Lite! https://www.numfocus.org/programs/john-hunter-technology-fellowship

All 10 comments

Hi @choldgraf – it turns out if you dig into the very early commits in altair, we did have the beginnings of a matplotlib renderer for early versions of Vega-Lite specifications (See e.g. this file) Long-term it would be great to revisit this. I think it would be straightforward to render the most common pieces of the spec with matplotlib, but getting to 100% schema support would be a pretty substantial effort.

I'd be happy to see work in this area, but I probably won't be able to tackle it myself any time soon!

Yeah to me it kind of seems this would be more of a "trickle" feature than an all-at-once kind of thing (e.g. "Altair now supports exporting scatterplots to matplotlib"). I think it'd be a good test-case for what it'd actually look like if the vega-lite spec was a universal plotting spec.

Maybe I can play around with this in the coming months...just gauging interest and importance from you guys now :)

Eventually I'd love this to live in a separate package under the altair-viz organization. If you get a prototype working, please let us know!

ya I think that's a good idea too. I'll keep you updated if I start working on anything - want me to keep this issue open?

Yes, let's keep it open

@choldgraf Yeah I think it would be exciting to see this happening.

Btw, it's worth noting that we (VL team) are working on Vega-Lite 2.0, which means there might be some breaking syntax change due to changes in Vega 3 and D3 4.0.

That said, I think it's probably doesn't hurt to start hacking a prototype. But of course it's definitely worth waiting before doing a full-blown Altair/VL to matplotlib compiler.

I've started a repo at http://github.com/altair-viz/altair_matplotlib

Not a lot there yet... and it turned out the old code wasn't really salvageable given the changes to Altair since then.

Note that the 2018 John Hunter Fellowship will support work on a matplotlib renderer for Altair/Vega-Lite! https://www.numfocus.org/programs/john-hunter-technology-fellowship

Has there been any further work on this? Really like the idea of using Vega-Lite as a common language layer for the many Python visualization packages, starting with Matplotlib!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nielsmde picture nielsmde  Â·  4Comments

morberg picture morberg  Â·  3Comments

LukeMathWalker picture LukeMathWalker  Â·  3Comments

HalukaMB picture HalukaMB  Â·  3Comments

tonylee3399 picture tonylee3399  Â·  3Comments