2

have a a plot that is similar to this (almost) minimal example here:

\documentclass{beamer}

\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
\begin{frame}
    \begin{tikzpicture}
        \begin{axis}[
            axis x line = bottom,
            axis y line = left,
            ]

            \addplot3[
                samples at = {1.3, 2, 2.55, 3.5, 5.7, 12},
                samples y =0,
                point meta=(x-0.5)^2 + y^2,
                mark = *,
                only marks,
                scatter,
                ]
                ({sin(x)}, {cos(x)}, {1/x});
        \end{axis}
    \end{tikzpicture}
\end{frame}
\end{document}

Is it possible to uncover the single samples one at a time with beamer overlays?

2 Answers 2

3

You can use the overlay-beamer-styles library:

\documentclass{beamer}

\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{overlay-beamer-styles}

\begin{document}
\begin{frame}
    \begin{tikzpicture}
        \begin{axis}[
            axis x line = bottom,
            axis y line = left,
            ]

            \addplot3[
                samples at = {1.3, 2, 2.55, 3.5, 5.7,12},
                samples y =0,
                point meta=(x-0.5)^2 + y^2,
                mark = *,
                only marks,
                scatter,
                scatter src=z,
                scatter/use mapped color={draw=mapped
                color!80!black,fill=mapped color,visible on=<+->}
            ]
                ({sin(x)}, {cos(x)}, {1/x});
        \end{axis}
    \end{tikzpicture}
\end{frame}
\end{document}

enter image description here

8
  • Haha. You gave the hint with overlay-beamer-styles just two days ago in another post of mine. I didn't see how I could use it here. Ty.
    – Franz
    Aug 7 at 11:42
  • @Franz You're welcome! Aug 7 at 11:43
  • Where can I actually find the documentation for tikz libraries? I tried to search for "CTAN overlay-beamer-styles" but did not find anything useful. The tikz/pgfplots documentation also does not mention it.
    – Franz
    Aug 7 at 19:16
  • Ok. The name was so obscure that I didn't recognized it as overlay-beamer-styles. The documentation and the features also seem kind of sparse, e.g., I was looking for an alert on= command but could find it.
    – Franz
    Aug 8 at 0:07
3

A version not using any library, just adding \pause via scatter/@post marker code:

\documentclass{beamer}

\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
\begin{frame}
    \begin{tikzpicture}
        \begin{axis}[
            axis x line = bottom,
            axis y line = left,
            scatter/@pre marker code/.code={},
            scatter/@post marker code/.code={\pause}
            ]

            \addplot3[
                samples at = {1.3, 2, 2.55, 3.5, 5.7, 12},
                samples y =0,
                point meta=(x-0.5)^2 + y^2,
                mark =*,
                only marks,
                scatter,
                ]
                ({sin(x)}, {cos(x)}, {1/x});
        \end{axis}
     \onslide<1->% see comments
    \end{tikzpicture}
\end{frame}
\end{document}
10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.