An exemple in order to save figures generated by PGFPlotsX

Julia 1.4.1
*Kubuntu 18.04 LST *
LaTeX + textlive-full (including LuaLaTeX) + ImageMagik
Documentation: PGFPlotsX.jl by Kristoffer Carlsson

Hello dear all,

Say that I am using an elementary code as follows, extracted from the here:

using PGFPlotsX
using LaTeXStrings

@pgf Axis(
    {
        xlabel = L"x",
        ylabel = L"f(x) = x^2 - x + 4"
    },
    Plot(
        Expression("x^2 - x + 4")
    )
)

In the documentation I note the general way to export .tex file or .svg figure

pgfsave(filename::AbstractString, figure; include_preamble::Bool = true, dpi = 150)

However I don’t see how to do in practice in order to obtain:

  • a .tex file which can be compiled in Kile for exemple

  • a figure.svg (or .pdf) to be saved.

I lauch prgms from a console with the command julia simple.jl

Thank you in advance for any reply,
Thierry

I am not sure if you read

https://kristofferc.github.io/PGFPlotsX.jl/stable/man/save.html

In any case,

p = @pgf Axis(
    {
        xlabel = L"x",
        ylabel = L"f(x) = x^2 - x + 4"
    },
    Plot(
        Expression("x^2 - x + 4")
    )
)

pgfsave("/tmp/x.tex", p)
pgfsave("/tmp/x.pdf", p)

works fine for me (I don’t know what Kile is, but the .tex file compiles find with pdflatex).

3 Likes

Thank you very much Tamas_Papp. Indeed the pgfsave instruction as you wrote it perfectly works.

I am sorry to have bothered you. These last days I read so much documentation about both"Gaston/Gnuplot" and “PGFPlotsX” that I couln’t find my way alone.

Kile is an integrated LaTeX editing environment.

Kind rgards,
T.

You haven’t (and I don’t think anything I wrote was meant to give that impression), as you did not contact me directly, just asked the question here and I was happy to help.

Enjoy PGFPlotsX, which is a therapeutic device for mitigating obsessive-compulsive visualization disorder, disguised as a Julia package.

Excellent! :grinning: