Plots.jl PGFplotsX backend is a massive boon for Julia

There’s a lot of talk of Makie replacing plots.jl. I get it. I’ve just started using Makie and I think it’s great. However, I’ve also just started realising the power of PGFplotsX as a plots/statsplots backend. For a start, easily creating violin plots from data for seamless integration in a LaTeX document is something I’ve been looking for for a long time. R + TikzDevice can do this but the output is much harder to tweak without lots of trial and error, since it’s a picture , not an axis. The real revelation for though was taking complex plots produced using BifurcationKit and doing the same. I really hope this is something that continues in Julia, the ability to produce a complex figure just by calling plot() and get a .tex output.

If there is a general trend towards using Makie Vs Plots for visualising the output of popular packages, it would be great to have some equivalent of TikzDevice to convert Cairo to tikz. I have no idea how difficult this would be (probably quite).

Edited first sentence, as it misrepresented @ChrisRackauckas


If someone was interested enough, it would be possible to just write a tikz backend for Makie which copies the CairoMakie implementation because both use the same 2D vector graphics operations anyway that you then find in pdfs or svgs. I guess the difference is whether you have the tikz intermediary or not, which can render your plot with different fonts in your latex document. But if you do change fonts from whatever makie used to calculate metrics you could end up with overlapping things that don’t look quite right. I’ve never used tikz though, so I might misunderstand what you’re really looking for here


I would also tend to imagine that changing the font after the fact could be problematic.

A bit off-topic, but I wonder if it wouldn’t be easier to support some sort of “editable format”, so that it’s easy to redraw the plot with a different theme. Maybe just saving with a serializer that also records the package versions (like JLSO) could already get us halfway there.

1 Like

The nice thing about a PGFplots/PGFplotsX backend is that the plot is still saved as a plot. So it’s straight forward to mess around with the theme in a LaTeX editor afterwards (if need be).

As a contributor to PGFPlotsX, I am always happy to hear that people find it useful.

However, note that tikz code uses LaTeX for rendering, and as such it is one or two orders of magnitude slower than almost everything else. The benefit is of course the really polished look and LaTeX integration, but the cost is considerable and may make this less than ideal for a general backend.


I think the dream would be (and is?) to have full RecipiesBase support in Makie.
I know there is partial support right now.

That way DiffEq etc just needs to contine to support RecipiesBase.
and Plots.jl (with all its backends) as well as Makie would just work with it.
I know there was talk a while ago of adding RecipiesBase support to Vegalite.jl also


Just wanted to add that I also find the PGFPlotsX backend for Plots incredibly helpful – as has been said, it’s necessarily slower than other backends, but I’ve found it invaluable when producing publication-ready figures directly from my Julia code. It would be a shame for the community to lose that functionality.

Regarding performance, I’ll often switch between backends depending upon what I’m doing – so I’ll e.g. use GR as I’m developing, but when it comes to writing up, I’ll switch to the backend PGFPlotsX backend.


I never worked with tikz, is there a good overview of the process of rendering via LaTeX available (afair LaTeX → TeX doesn’t do rendering but outputs display lists like dvi)?

Pgfplots uses Tikz/pgf, which first expands graphics to a set of primitives known as the “basic layer”, then that is expanded via a “system layer” (for PDF etc). Parts IX and X of its manual document these.

Since LaTeX wasn’t really designed for this kind of computation but is otherwise Turing-complete, it emulates decent floating point (pgfmath) and a lot other basic stuff… in TeX (of course more recent engines like LuaTeX get shortcuts and are faster).

Since Tikz is so closely tied to TeX and kind of the whole point is that you can escape to TeX any time, it is conceptually difficult to do this any other way.

Exactly. Let me make it clear that I won’t be deprecating or abandoning Plots.jl recipe support for the SciML ecosystem. Rather, I want to make sure it all works with Makie, and I myself want to then transition to Makie. The code won’t be deleted, it will be maintained, but likely it won’t grow much past that point unless it’s able to be written in a way where the same recipe pieces work with both systems. I’d hope other systems support such recipes to, but it’s not that easy.


Actually, changing fonts (both sizes and typeface) in pgfplots works incredibly well. pgfplots is a high-level description of the plot, most of the time you write stuff like ‘put this below left of that, make the lines really thick, and put extra spacing around it,’ etc. The lower level layout engine (and TeX itself) will make it look right.

You can do much more dramatic changes than fonts, even change the aspect ratio of your plot after the fact, and it still comes out right.

Pgfplots and tikz are real TeX formats, I cannot overstate how well it works with LaTeX documents.

On the flip side, this makes it non-trivial to use pgfplots as a ‘backend’, you rather need something like a ‘translator’ that re-creates your plot in the pgfplots style. Alternatively, you use the tikz or pgf commands directly to ‘dumbly’ export the graphics commands on a lower level, but then lose some of the flexibility and adaptability of the higher level description.


Continuing on DNF’s comment, there are two concrete examples of software interaction with TikZ/Pgfplots (that I know of at least) :

  • Inkscape’s TikZ export which is as DNF said relatively dumb as it is based on very low level objects.
  • The matlab2tikz tool for matlab (and it’s python counterpart tikzplotlib) which I personally use a lot when I’m on matlab and which are much more high level as they mostly work with pgfplots axes.

we are actually half way there. Last VizCon RecipesPipeline was split from Plots.jl and there was a time when MakieRecipes consumed DiffEq-recipes.
But Makie is evolving fast and so that got left behind. One day it will catch up.