# Undefined control sequence: \pgfplots@data@xmin

I am trying to use Jake's excellent Tufte y bar chart style but I am getting an

! Undefined control sequence.
<argument> {rel axis cs:0,0}-|{axis cs:\pgfplots
@data@xmin,0}
l.54     \end{axis}


when trying to draw the x-axis. I've installed TexLive from the website on Ubuntu 12.04 and, according to tlmgr info <package> am using pgf version 2.10 and pgfplots version 1.7. NB: My tufte ybar is slightly adjusted but not in the critical part of the code, and I get the same error when using the code provided by Jake in his original post.

MWE:

\documentclass{article}
\usepackage{filecontents}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

%% Color definitions
\definecolor{tufte1}{rgb}{0.7,0.7,0.55}

%% Tufte-style Y bar chart
\pgfplotsset{
tufte ybar/.style={
ybar,
hide x axis,
axis line style={opacity=0},
major tick style={draw=none},
ymin=0,
bar width=0.7em,
ymajorgrids,
major grid style=white,
axis on top,
cycle list={
fill=tufte1, draw=none\\
},
after end axis/.code={
\draw [very thick, tufte1] ({rel axis cs:0,0}
-|{axis cs:\pgfplots@data@xmin,0})
++(-0.5*\pgfkeysvalueof{/pgf/bar width},0pt)
-- ({rel axis cs:0,0}-|{axis cs:\pgfplots@data@xmax,0})
-- ++(0.5*\pgfkeysvalueof{/pgf/bar width},0pt);
},
}
}

\begin{filecontents}{mwe.dat}
1,3
2,1
3,16
4,0
5,13
6,3
7,33
8,1
9,26
\end{filecontents}

\begin{document}
\begin{tikzpicture}
\begin{axis}[tufte ybar, width=\textwidth,
ytick={5,10,...,35}, yticklabel style={font=\tiny},
nodes near coords, every node near coord/.append style={font=\tiny}
]
\end{axis}
\end{tikzpicture}
\end{document}

-
What do \makeatletter and \makeatother do? This is basically the same as in a question I answered not long ago. – Qrrbrbirlbel Feb 23 '13 at 19:40
What @Qrrbrbirlbel is saying is to add \makeatletter before, and \makeatother after pgfplotsset as per the link provided. – Peter Grill Feb 23 '13 at 19:42
@Qrrbrbirlbel Thanks, that indeed solved the problem. I'm guessing it's a fairly common problem for users not familiar with actual Tex syntax but one very hard to Google for :( I know what \makeatletter and \makeatother do in principle, but didn't realise that's where the problem was ... If one of you wants to post it as an answer, I'll be glad to accept it. – ThomasH Feb 23 '13 at 19:51

As per What do \makeatletter and \makeatother do? you need to enclose the \pgfplotsset command that uses macros with an @ in their names between \makeatletter and \makeatother.

Otherwise it sees only \pgfplots as a macro which is indeed not defined:

! Undefined control sequence.
<argument> {rel axis cs:0,0} -|{axis cs:\pgfplots
@data@xmin,0}
l.56     \end{axis}

The control sequence at the end of the top line
of your error message was never \def'ed.


## Code

\documentclass{article}
\usepackage{filecontents}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

%% Color definitions
\definecolor{tufte1}{rgb}{0.7,0.7,0.55}

%% Tufte-style Y bar chart
\makeatletter
\pgfplotsset{
tufte ybar/.style={
ybar,
hide x axis,
axis line style={opacity=0},
major tick style={draw=none},
ymin=0,
bar width=0.7em,
ymajorgrids,
major grid style=white,
axis on top,
cycle list={
fill=tufte1, draw=none\\
},
after end axis/.code={
\draw [very thick, tufte1] ({rel axis cs:0,0}
-|{axis cs:\pgfplots@data@xmin,0})
++(-0.5*\pgfkeysvalueof{/pgf/bar width},0pt)
-- ({rel axis cs:0,0}-|{axis cs:\pgfplots@data@xmax,0})
-- ++(0.5*\pgfkeysvalueof{/pgf/bar width},0pt);
},
}
}
\makeatother

\begin{filecontents}{mwe.dat}
1,3
2,1
3,16
4,0
5,13
6,3
7,33
8,1
9,26
\end{filecontents}

\begin{document}
\begin{tikzpicture}
\begin{axis}[tufte ybar, width=\textwidth,
ytick={5,10,...,35}, yticklabel style={font=\tiny},
nodes near coords, every node near coord/.append style={font=\tiny}
]