PGFPlotsX.jl to LaTeX

Hi everyone,

I am want to try using PGFPlotsX.jl via Plots.jl to export .tex files that are to be included in my LyX document. But if I try to use \input{myplot.tex} in my file, I get the following error messages:

image

I have \usepackage{tikz} \usepackage{pgfplots} at the top of my LaTeX file. Is there something else I need to do? The beginning of myplot.tex is

\begin{tikzpicture}[/tikz/background rectangle/.style={fill={rgb,1:red,1.0;green,1.0;blue,1.0}, draw opacity={1.0}}, show background rectangle]

You can see the header necessary in the Variable PGFPlotsX.DEFAULT_PREAMBLE:

julia> PGFPlotsX.DEFAULT_PREAMBLE
7-element Array{String,1}:
 "\\usepackage{pgfplots}"
 "\\pgfplotsset{compat=newest}"
 "\\usepgfplotslibrary{groupplots}"
 "\\usepgfplotslibrary{polar}"
 "\\usepgfplotslibrary{smithchart}"
 "\\usepgfplotslibrary{statistics}"
 "\\usepgfplotslibrary{dateplot}"
4 Likes

So I tried the following:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{groupplots}
\usepgfplotslibrary{polar}
\usepgfplotslibrary{smithchart}
\usepgfplotslibrary{statistics}
\usepgfplotslibrary{dateplot}

\begin{document}
\input{myplot.tikz}
\end{document}

And it gives me the same error.

Ok, I have got it now. You need to import also

\usetikzlibrary{backgrounds}
\usepgfplotslibrary{fillbetween}
1 Like

https://tex.stackexchange.com/a/6903 says \usetikzlibrary{intersections}

1 Like

You can query the preamble used by the Plots backend with Plots.pgfx_preamble().
This is the relevant section of the documentation for this.

2 Likes