PGFPlotsX (GitHub - KristofferC/PGFPlotsX.jl: Plots in Julia using the PGFPlots LaTeX package) is (yet another) plotting package that aims to provide a convenient way of using PGFPlots (a plotting library for LaTeX) from Julia.
We (me and @Tamas_Papp ) have chosen to make the API such that the syntax written in Julia has a similar structure to the one you would write in LaTeX. PGFPlots is a mature plotting library and has tons of documentation and examples and since the structure is similar, it is quite easy to adopt example you see given in LaTeX to Julia. The advantage of doing stuff in Julia is, of course, that we can directly use our data from the analysis we run and that programming in Julia is much nicer than in LaTeX.

The original reason for creating this package was that I really wanted to use PGFPlots to generate the figures for one of my papers to keep the typesetting consistent with the rest of the paper.
I was however not at all happy with the ways I could do that from Julia, most of the things I tried (Plots.jl, PGFPlots.jl) seemed to try to abstract away the PGFPlots-backend but I wanted direct access to it to be able to use all its features. Being able to directly (but with high convenience) use PGFPlots has been one of the core guiding principles.

To list some features:

  • Support for directly using some of the types defined in popular packages, for example Colors, DataFrames, StatsBase, Contours etc (see some examples at
  • PGFPlotsX takes about 1.5s to load and around 1-2 seconds for the first plot to show up.
  • The generated figures are shown inline in IJulia, Juno and VSCode.
  • Figures can be exported to pdf, svg, png and also to tex to directly be included in e.g. a scientific paper.

Happy plotting!


Fantastic, I will give this a try.

For those unfamiliar with pgfplots (the LaTeX package), see their gallery. These are all in LaTeX, but can be easily translated to the syntax used by PGFPlotsX. Also, the collection of all the plots in their pgfplots manual is a good reference.

It is important to note that this package is not the solution to all Julia plotting woes, but is a good alternative for those who want to use their plots in papers using TeX and/or like pgfplots already.


How is its performance? I really like Gadfly, but it is slow.

See above:

That said, plots with a lot of data points can strain LaTeX. The default engine is LuaLaTeX though, which is better.

As Tamas says, since PGFPlotsX just compiles to tex where the rendering takes place, that is usually where the bottleneck is.

While it is possible to make figures like:

(using the following code)

function julia(z, maxiter)
    c = -0.742 + 0.1im
    for n = 1:maxiter
        abs2(z) > 4 && return n-1
        z = z^2 + c
    return 0

x = linspace(-2, 2, 250)
y = linspace(-1, 1, 250)
m = (x, y) -> julia(complex(x, y), 10000)

@pgf Axis(
        width = "14cm",
        view = (0, 90),
            shader = "interp",
        Coordinates(x, y, m.(x, y'));

it is quite slow. I would say PGFPlots works best when you have quite simple figures.

1 Like

Iā€™m using this package and I LOVE it!!! You people did an amazing job! Thank you!


Wow, as someone that spends way too much time plotting things in Tikz/PGFPlots, this might be a huge time saver!

1 Like