We use the pgf backend of matplotlib to create publication quality pdf plots.
The example uses the modern lualatex engine, so you'll need a relatively
recent TeXLive, everything >= 2016 should work.
The method itself also supports pdflatex and xelatex.
For more information see: