3

I have this problem. When I am using the library overlay-beamer-styles with spy and opacity, spy doesn't work well.

The problem starts when I use visible on=<> with two different \spy and introduce opacity to the image. This is the code:

\documentclass[compress]{beamer}

\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc, spy, overlay-beamer-styles, backgrounds}

\begin{document}

\begin{frame}
\centering
\begin{tikzpicture}[spy using overlays,
    spy using outlines={circle,
    size=1cm,
    connect spies}
    ]
    \pgfmathsetseed{10}
    \newcommand{\Xa}{1.75}
    \newcommand{\Ya}{2}
    \newcommand{\Ca}{.9}
    \node (a) at (\Xa,\Ya) {};

    \foreach \p in {1,...,100}{
        \pgfmathsetmacro{\xx}{\Ca*rand}
        \coordinate (pta) at (1.5*\xx+\Xa,{rand*sqrt(\Ca^2-(\xx)^2)+\Ya});
        \fill[opacity=.2, visible on=<1>] (pta) circle (0.04);
        }
    \spy[magnification=1.5, visible on=<1>] on (a) in node at (2.5,5);
    \spy[magnification=2.5, visible on=<2>] on (1.5,1.5) in node at (2.5,5);
\end{tikzpicture}
\end{frame}

\end{document}

enter image description here enter image description here

Even if there are no points, the second \spy overlays taking only opacity of \fill. I have another example:

enter image description here enter image description here

Some parts of the second \spy are shown with opacity in the previous \spy.

1 Answer 1

2

You can avoid the problem by using \only<>{...} to make sure each spy is only on a single slide:

\documentclass[compress]{beamer}

\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc, spy, overlay-beamer-styles, backgrounds}

\begin{document}

\begin{frame}
\centering
\begin{tikzpicture}[spy using overlays,
    spy using outlines={circle,
    size=1cm,
    connect spies}
    ]
    \pgfmathsetseed{10}
    \newcommand{\Xa}{1.75}
    \newcommand{\Ya}{2}
    \newcommand{\Ca}{.9}
    \node (a) at (\Xa,\Ya) {};

    \foreach \p in {1,...,100}{
        \pgfmathsetmacro{\xx}{\Ca*rand}
        \coordinate (pta) at (1.5*\xx+\Xa,{rand*sqrt(\Ca^2-(\xx)^2)+\Ya});
        \fill[opacity=.2] (pta) circle (0.04);
        }
    \only<1>{\spy[magnification=1.5] on (a) in node at (2.5,5);}
    \only<2>{\spy[magnification=2.5, visible on=<2>] on (1.5,1.5) in node at (2.5,5);}
\end{tikzpicture}
\end{frame}

\end{document}

enter image description here

You must log in to answer this question.

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