# Typesetting one symbolic coord differently than the others

In my plots, I have one bar (labelled dummy below) whose tick label needs to be typeset differently. Here's my current attempt (and minimal example), which doesn't quite work yet:

\documentclass{article}

\usepackage{pgfplots}
\usepackage{etoolbox}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
symbolic x coords={foo,bar,dummy},
xtick=data,
xticklabel={\ifdefstrequal{\tick}{dummy}{\textcolor{gray}{\tick}}{\tick}}]
(foo,2)
(bar,4)
(dummy,3)
};
\end{axis}
\end{tikzpicture}
\end{document}


Now, I definitely need matching on the symbolic x coords name; comparing the \ticknum is unfortunately not an option, as the position of the dummy bar changes from plot to plot, and I don't want to touch the definition of xticklabel each time. So is there a way to do an appropriate string comparison with \tick?

-
In your actual application, will you provide your data as coordinates, or do they come in a file/table? –  Jake Apr 15 '12 at 14:16
I'm using coordinates. If the solution would work for table too, however, that would be great. –  Andreas Apr 15 '12 at 14:33

You could use the ifthen package:

\documentclass{article}

\usepackage{pgfplots}
\usepackage{ifthen}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
symbolic x coords={foo,bar,dummy},
xtick=data,
xticklabel=\ifthenelse{\equal{\tick}{dummy}}{\textcolor{red}{\tick}}{\tick}]
(foo,2)
(bar,4)
(dummy,3)
};
\end{axis}
\end{tikzpicture}
\end{document}


If you want to use etoolbox, you'll have to use \ifdefstring{<macro>}{<string>}, which compares the content of a macro to a string.

\documentclass{article}

\usepackage{pgfplots}
\usepackage{etoolbox}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
symbolic x coords={foo,bar,dummy},
xtick=data,
xticklabel=\ifdefstring{\tick}{dummy}{\textcolor{red}{\tick}}{\tick}]

Works. But out of curiosity, how would a solution using etoolbox look like, in particular in the light of Why is the ifthen package obsolete? –  Andreas Apr 15 '12 at 16:02
@Andreas: I've edited my answer to show how to do it with etoolbox. –  Jake Apr 15 '12 at 16:06