According to percusses answer in Argument to \input or \include statement? both height and width in the axis environment in PGFplots may be set externally (outside the axis environment) with a nested \pgfplotsset statement:
\pgfplotsset{execute at begin axis={\pgfplotsset{width=5cm}}}
However, if I try to apply the same concept to xmin, xmax, ymin and ymax according to the answer suggested by Piotr, pgfplotsset doesn't seem to override the settings given within the axis environment.
Consider the following MWE:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
{ % begin outer pgfplotsset scope
\pgfplotsset{ymax=5, ymin=1, execute at begin axis={\pgfplotsset{width=5cm}}}
\begin{tikzpicture}
\begin{axis}[width=10cm, ymin=0]
\addplot {x^2};
\end{axis}
\end{tikzpicture}
} % end outer pgfplotsset scope
\end{document}
which produces the following graph, where ymin clearly is 0, though I just set it ymin=1 in pgfplotsset.

What I want to achieve
Set xmin, xmax, ymin and ymax from outside the axis environment (in a similar way as I do with width applying execute at begin axis in pgsplotsset), even though they also will be specified in \begin{axis}[]. The external call to xmin etc. should override the values set in \begin{axis}[].


execute at begin axisis probably executed after the option you provide. This does not happen if you use theevery axis(which is applied before any local options) style:every axis/.append style={width=5cm}. Theymin=0overwrites theymin=1setting from before. – Qrrbrbirlbel May 16 '13 at 09:57execute at begin axiscode is executed after the[ ]axis options. Of courseymin=0overwrites a previous setymin=1. – Qrrbrbirlbel May 16 '13 at 11:42