Plots.jl with PGFPlotsX backend produces plot way of center

TheBigZet
Wed, 19 Apr 2023 20:30:30 +0000
Visualization

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)
end

p = plot(xlabel = L"x[mm]", ylabel = L"\varepsilon_y [10^{-3}]")
title!(L"\varepsilon_y(x)")
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:

\documentclass{article}
\usepackage{amsmath}
\usepackage{polski}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{float}
% Recommended preamble:
\begin{document}
    \usetikzlibrary{arrows.meta}
    \usetikzlibrary{backgrounds}
    \usepgfplotslibrary{patchplots}
    \usepgfplotslibrary{fillbetween}
    \pgfplotsset{%
        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},%
        },
    }
    \begin{figure}[H]
        \centering
        \input{p.tikz}
        \caption{Caption 123}
    \end{figure}
\end{document}

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

3 posts - 3 participants