rsmf
rsmf copied to clipboard
Altair support
Altair is a 2D plotting library based on grammar of graphics (like R's ggplot2), typically producing Vega-Lite output (for interactive web output). Static figures can also be saved as PDF or SVG using altair_saver. If you're willing to abstract matplotlib in rsmf, it seems it would be feasible to also support Altair, which would enable use of the same plotting platform for interactive figures in HTML talks as well as PDF figures in static papers.
I agree that it seems feasible. But I first have to understand a few things:
- The purpose of rsmf is to format figures for use with LaTeX. To obtain the same optics, the pgf backend of matplotlib is used which is essentially rendering the figure through LaTeX, ensuring coherent optics. Does Altair have a similar, LaTeX-compatible backend? If not, ensuring the correct fonts are used will be super hackish.
- HTML talks are somewhat out of scope for rsmf, as it is built to pull the information of how to setup the PGF backend from TeX. So I don't see how rsmf would bring a benefit there?
There is no analog to matplotlib's pgf backend. @jakevdp may have thoughts on how difficult it would be to teach Altair to save using PGF or similar.
I didn't mean to imply that rsmf would be used for HTML plots. Rather, that a single visualization would be created using Altair to be used in talks/websites, and use rsmf to help make the fonts paper-friendly. My present workflow has been to either live with font mismatch or to recreate a similar figure using matplotlib, but that requires remembering (and teaching or expecting students to learn) two disparate plotting interfaces.
The vega-cli package has methods to save vega/vega-lite charts to png, svg, and pdf. If none of those are suitable for the purposes here, that package would be the place to implement other formats.
It seems like all the existing outputs in vega-cli go through Vega's renderHeadless()
so we'd be looking for JavaScript libraries that output pgf/latex. My search didn't turn up much, but I'm very unfamiliar with the JS ecosystem.
Okay, but from this vantage point it looks like supporting vega would first require some changes on the vega side. I think the important features to add to rsmf before this can be addressed are additional journal venues. So I'd postpone a possible vega integration.