Plots.jl with PGFPlotsX backend produces plot way of center

This simple Julia code:

using Plots; pgfplotsx();
using LaTeXStrings

x = [-243, 144, 243]
e1 = [120, 149, 26]
e2 = [218, 271, 68]
e3 = [314, 380, 148]

function plot_eps(p, x, y, color, label)
    plot!(p, x, y, label = label, linecolor = color)

p = plot(xlabel = L"x[mm]", ylabel = L"\varepsilon_y [10^{-3}]")
plot_eps(p, x, e1, "red", L"\varepsilon_1")
plot_eps(p, x, e2, "blue", L"\varepsilon_2")
plot_eps(p, x, e3, "green", L"\varepsilon_3")
savefig(p, "p.tikz")

with this simple LaTeX code:

% Recommended preamble:
        layers/standard/.define layer set={%
            background,axis background,axis grid,axis ticks,axis lines,axis tick labels,pre main,main,axis descriptions,axis foreground%
            grid style={/pgfplots/on layer=axis grid},%
            tick style={/pgfplots/on layer=axis ticks},%
            axis line style={/pgfplots/on layer=axis lines},%
            label style={/pgfplots/on layer=axis descriptions},%
            legend style={/pgfplots/on layer=axis descriptions},%
            title style={/pgfplots/on layer=axis descriptions},%
            colorbar style={/pgfplots/on layer=axis descriptions},%
            ticklabel style={/pgfplots/on layer=axis tick labels},%
            axis background@ style={/pgfplots/on layer=axis background},%
            3d box foreground style={/pgfplots/on layer=axis foreground},%
        \caption{Caption 123}

produces pdf file where the plot’s appearance is disgusting

Is it Julia or LaTeX issue?
Also, how can I change the scaling of the .tikz file? The solution in “docs” doesn’t work for me as \includegraphics doesn’t like .tikz files Backends · Plots

I could also complain about usefulness (or rather lack of) Julia packages documentation in general, but that’s another topic

See this other thread, with related complaints and this expert response.
Plots.jl is a handy calling platform for many different backends that is pretty good. For the picky, please use the original interface package, in this case PGFPlotsX.jl.

You can find a working example of including figures in \LaTeX documents here.

To use .tikz files with includegraphics you need to load the tikzscale package.

1 Like