# How to access \xmin, \xmax, \ymin, \ymax from within PGFplots axis environment

In the MWE example below I have the values specified twice, but would prefer not to have to do that. Furthermore, it is possible to allow PGFplots to automatically select these end points so I would have to iterate and modify the settings manually after seeing what PGFplots had selected. There must be some way to access these variables form within the axis environment:

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
\begin{axis}[xmin=-1.5, xmax=1.5, ymin=-1, ymax=3]

% Would prefer to be able to specify something like this:
%\addplot [mark=none, blue, ultra thick] coordinates {(\xmin,\ymin) (\xmin,\ymax)};

% But until I can access those values, do it manually:
\addplot [mark=none, blue, ultra thick] coordinates {(-1.5,-1) (-1.5,3)};

\end{axis}
\end{tikzpicture}
\end{document}


In case there is an interest in why I want to do this: I am trying to automate labelling intersections with the lines x=0 and y=0 within PGFplots as discussed in How to specify a name path for the axis in PGFplots. However, there are issues with that approach. One solution (albeit it is a bit of a hack) is to draw the lines x=0, and y=0 with draw=none option and then find the intersection with that. If I can access the min/max values of the x and y axis then I can label a phantom line and automate the location of the intersections via Intersections in PGFplots

-

You can access the values of xmin, xmax, etc. through \pgfkeysvalueof{/pgfplots/xmin}. This only works if they have been set explicitly in the axis options, though, so it is most likely not what you want. Instead, you should use the nodes current axis.above origin, current axis.below origin, current axis.left of origin and current axis.right of origin.

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
\begin{axis}[]

\draw (current axis.above origin) -- (current axis.below origin);
\draw (current axis.left of origin) -- (current axis.right of origin);

\end{axis}
\end{tikzpicture}
\end{document}


-

Like Jake says, xmin, etc. can only be accessed and stored via pgfkeysvalueof{/pgfplots/xmin} and \pgfkeysgetvalue{/pgfplots/xmin}{\xmin} respectively, when xmin has been set explicitly.

Nonetheless besides the mentioned current axis.above origin, etc., PGFplots also offers current axis.south west, etc.. These represent nodes with coordinates (xmin,ymin), etc., which is what you were looking for I believe.

However, I, unfortunately, do not know how to extract a x or y from the node coordinate. At Extract the x/y part from a coordinate in pgfplots it is stated that one can do so by means of \newdimen\mydim, \pgfextractx\mydim{\pgfpointanchor{A}{center}} but I cannot seem to get it to work.

-