LaTeX friendly vector graphics with Makie

jlbosse
Sun, 24 Jul 2022 11:38:43 +0000
Visualization

Is there a way to produce vector graphics figures with Makie such that they can be included in a LaTeX document and have LaTeX typeset all text in the figure? My first idea was to use CairoMakie to produce a figure.svg file and then use

inkscape -D --export-latex --export-filename=figure.pdf figure.svg

to create a figure.pdf and figure.pdf_tex file that can be included and where figure.pdf_tex contains all text in the figure. But upon closer inspection of the SVG files it turns out that the text in it is actually not text anymore, but just vector graphics outlines of the letters.

As you can see, the fonts in the figure don’t match the document font and would stay unchanged when changin the document font,

Similarly, if I use CairoMakie to produce a PDF figure and

inkscape -D --export-latex --export-filename=figure.pdf figure.svg

to put the text into a separate .pdf_tex file the fonts match now, but the spacing is completely off:

And \includegraphicing the PDF produced by CairoMakie directly yields

My end goal is to be able to include my Makie figures in LaTeX documents and have the fonts in the figure and the main document automatically match and being able to use fonts other than computer modern for LaTeX elements in the figure (which seems to be the only font support by MathTexEngine).

In a similar vein: Are there any plany to write a PGFMakie backend for Makie? In matplotlib / pyplot I can do fig.savefig("filename.pgf") to produce a file that I can directly \input into my LaTeX document and the lack of such an option is the only thing still preventing me from switching to Makie for my plotting needs.

4 posts - 4 participants