# 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}
]
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.8261747360229492, "perplexity": 14945.752045726535}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2015-06/segments/1422121478981.94/warc/CC-MAIN-20150124174438-00239-ip-10-180-212-252.ec2.internal.warc.gz"}