# Plots.jl with PGFPlotsX backend produces plot way of center

**URL:** https://discourse.julialang.org/t/plots-jl-with-pgfplotsx-backend-produces-plot-way-of-center/97678
**Category:** Visualization
**Tags:** question, plotting, pgfplotsx
**Created:** [April 19, 2023, 8:30pm UTC](https://discourse.julialang.org/t/plots-jl-with-pgfplotsx-backend-produces-plot-way-of-center/97678 "2023-04-19T20:30:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![TheBigZet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thebigzet/32/49153_2.png) [@TheBigZet](https://discourse.julialang.org/u/TheBigZet)
#### Post date: [April 19, 2023, 8:30pm UTC](https://discourse.julialang.org/t/plots-jl-with-pgfplotsx-backend-produces-plot-way-of-center/97678/1 "2023-04-19T20:30:30Z")

</div>

This simple Julia code:

```julia
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:

```julia
\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

 ![pdf_screenshot](https://global.discourse-cdn.com/julialang/original/3X/c/0/c06a6421e47e05a7201e139efa77edceb80fe7cc.jpeg)  
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](https://docs.juliaplots.org/latest/backends/#%5BPGFPlotsX%5D(https://github.com/KristofferC/PGFPlotsX.jl))

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

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [April 19, 2023, 8:45pm UTC](https://discourse.julialang.org/t/plots-jl-with-pgfplotsx-backend-produces-plot-way-of-center/97678/2 "2023-04-19T20:45:50Z")

</div>

See this other thread, with related complaints and [this expert response](https://discourse.julialang.org/t/back-to-pyplot/97556/23).  
`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](https://kristofferc.github.io/PGFPlotsX.jl/stable/).

---

<div class="post-metadata">

### Author: ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)
#### Post date: [April 20, 2023, 6:55am UTC](https://discourse.julialang.org/t/plots-jl-with-pgfplotsx-backend-produces-plot-way-of-center/97678/3 "2023-04-20T06:55:50Z")

</div>

You can find a working example of including figures in \LaTeX documents [here](https://comp-bio.idmpages.uni-h.de/teaching/julia-physics-report/Requirements.html#a-minimal-report).

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