# using Beamer alert in pgfplots figures

I would like to add \alert to certain parts of graphs in a Beamer presentation while I'm talking about them, namely highlighting pgfplots values.

I managed to higlight labels by using \alert<2>{...}, but I'm not sure how to go about highlighting the values.

Here is a MWE including a sample graph:

\documentclass[14pt]{beamer}

\usepackage{siunitx}
\sisetup{
output-decimal-marker={,},
group-separator={\,},
}
\def\ScanPercentage#1\afternumber{\SI{#1}{\percent}}

\usepackage{pgfplots}

% ---------------------------------------------------------------------------- %

\begin{document}
\begin{frame}{Bar Chart}
\begin{figure}
\scriptsize
\centering
\begin{tikzpicture}
\begin{axis}[
symbolic x coords={18--24, 25--34, 35--44, 45--54},
xtick=data,
ylabel={Group 1},
xlabel={Group 2},
ymin=0, ymax=60,
nodes near coords={\pgfmathprintnumber\pgfplotspointmeta{ }\%},
yticklabel={\pgfmathparse{\tick}\pgfmathprintnumber{\pgfmathresult}{ }\%},]
(18--24, 18.9)
(25--34, 48.4)
(35--44, 18.0)
(45--54, 14.7)
};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}


Here is a possible way to do that. (I am also loading overlay-beamer-styles here even though at this point it is not yet needed, so at this point this is only to draw your attention to this nice library.)

\documentclass[14pt]{beamer}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{overlay-beamer-styles}
\newcounter{nnc}
% ---------------------------------------------------------------------------- %
\begin{document}
\begin{frame}{Bar Chart}
\begin{figure}
\scriptsize
\centering\setcounter{nnc}{0}
\begin{tikzpicture}
\begin{axis}[
symbolic x coords={18--24, 25--34, 35--44, 45--54},
xtick=data,
ylabel={Group 1},
xlabel={Group 2},
ymin=0, ymax=60,
nodes near coords={\stepcounter{nnc}%
yticklabel={\pgfmathparse{\tick}\pgfmathprintnumber{\pgfmathresult}{ }\%},]
(18--24, 18.9)
(25--34, 48.4)
(35--44, 18.0)
(45--54, 14.7)
};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}


• Thanks, that's pretty much what I imagined. Splitting the question in two sounds like a good idea, what do you suggest I do? – Tomáš Sláma Apr 6 at 18:32
• @TomášSláma You could just drop the first part of your question in this post and use it as a second question. Asking questions is free (and even appreciated if they are new, like yours, I think, are.) – user121799 Apr 6 at 18:34
• I will do that then. Thanks so much for your help! – Tomáš Sláma Apr 6 at 18:36