Yesterday I posted about creating bar charts with TikZ and pgfplots.
Today I want to present a command to make the bars of one data series (i.e., one of my systems) appear one after the other on a beamer LaTeX slide.
This is the code to put into your preamble:
\newcounter{MyNextSlide} \newcounter{MyNextNextSlide} \newcommand{\addplotoverlay}[5][]{ \setcounter{MyNextSlide}{#5} \stepcounter{MyNextSlide} \setcounter{MyNextNextSlide}{\theMyNextSlide} \stepcounter{MyNextNextSlide} \alt<#5->{\only<#5->{\alt<\theMyNextSlide->{\alt<\theMyNextNextSlide->{ \addplot+ [ybar,#1] coordinates {#2 #3 #4}; }{ \addplot+ [ybar,#1] coordinates {#2 #3}; }}{ \addplot+ [ybar,#1] coordinates {#2}; }}}{ \addplot+ [ybar,#1] coordinates {(PI,0)}; % + don't show zero values in plot } }
Usage (‘first slide’ refers to the slide on which value 1 should first appear, it will stay and the slide afterwards will add value 2, the slide after that will add value 3):
\addplotoverlay [color or other options] {value 1}{value 2}{value 3}{first slide}
This depends on there being three data points in a data series and I have hardcoded the x coordinate PI. You’ll probably need to adjust this before you are able to do something useful with this code.