When working with pgf-tikz, I can create overlays in beamer presentations with

\path<overlay specification> ...

However, I could not get this to work in pgfplots graphics. It would be nice if something like

\addplot<2-> {...};

worked as expected, but it does not. Any ideas?

2 Answers 2


Well, it seems that

\only<overlay specification>{\addplot { ... };}

works fine, so problem solved. I had tried with the commands \visible and uncover but it did not work.

  • 23
    \draw, \path, and \node are overlay-specification-aware, but \addplot comes from another package built on top of pgf and isn't. \only works because it either includes or throws away its argument, whereas \uncover will try to set it in invisible ink, which it's not set up to do within a tikzpicture. The only drawback of \only over \uncover is you might need to manually correct the bounding box. Dec 6, 2010 at 19:57
  • 12
    Six years later, I googled this issue and stumbled on my own comment. Wish I could vote it up! Sep 28, 2016 at 15:19

This answer is adapted from this one by @gonzalo-medina.

You can use the visible on=<overlay specification> style provided by the overlay-beamer-styles library in the aobs-tikz package. The advantage over using \only is that the plot takes up space all the time but it is made invisible on the slides where it should not appear. As a result, the axis limits and dimensions of the plot will stay the same on all slides.


            \addplot {x};
            \addplot+[visible on=<2->] {x^2};

Slides showing a plot where the lines are added one by one.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .