I have to create a set of groupplots with pgfplots and want to use one centralized definition of the plot style (width, height, x-axis label, etc.). It seemed to me that this should be easily done by collecting the definitions in a file that I then input. The MWE is as follows:
\documentclass[10pt]{article}
\usepackage{tikz}
\usepackage{fancyhdr}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\pgfplotsset{compat=1.12}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}
\begin{groupplot}[
width=6.0cm,height=4.0cm,
group style={group size=1 by 2},
xmin=0.0,xmax=1.0,xlabel=$x$,
% \input{style.tex} % does not work
]
\nextgroupplot[ymin=0.0,ymax=1.0,ylabel={$y_2$}]
\addplot table {
0.1 0.9
0.9 0.1
};
\nextgroupplot[ymin=0.0,ymax=1.0,ylabel={$y_1$}]
\addplot table {
0.1 0.2
0.9 0.8
};
\end{groupplot}
\end{tikzpicture}
\end{document}
The file style.tex contains the following:
width=6.0cm,height=4.0cm,
group style={group size=1 by 2},
xmin=0.0,xmax=1.0,xlabel=$x$,
If I run the above MWE, pgfplots works as intended. If I comment out the lines that are reproduced in style.tex and comment in the line containing the \input command, I get the following error:
! Use of \pgfplots@@environment@groupplot doesn't match its definition.
\pgfutil@ifnextchar ...1\def \pgfutil@reserved@a {
#2}\def \pgfutil@reserved@...
l.17 ]
How come? I thought that the \input command is equivalent to typing out the commands in the file being input.


\pgfplotsset{...}which (for local use) should folow\begin{tikzpicture}. – Zarko Dec 27 '15 at 19:43