I noticed that nodes and/or magnifications created with the \spy macro provided by the spy library do not adhere to scoped transformations. If the transformations are defined explicitly the coordinates in the \spy macro, the transformation is applied correctly.
(PGF Version: 2021/05/15 v3.1.9a)
Minimal working example (MWE)
First MWE (shifted scope within spy scope):
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{spy}
\begin{document}
\begin{tikzpicture}[spy using outlines={magnification=4, size=1cm, connect spies}]
\draw[green] (0:0) circle[radius=1];
\spy[black!25] on (30:1)
in node at (0,0);
\begin{scope}[shift={(2.5cm,0)}]
\draw[green] (0:0) circle[radius=1];
\spy[red, circle] on (30:1)
in node at (0,0);
\end{scope}
\end{tikzpicture}
\end{document}
Obviously, spy nodes and magnified paths are not affected by scoped transformation.
Second MWE (spy scope only applied to scopes):
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{spy}
\begin{document}
\begin{tikzpicture}
\begin{scope}[spy using outlines={magnification=4, size=1cm, connect spies}]
\draw[green] (0:0) circle[radius=1];
\spy[black!25] on (30:1)
in node at (0,0);
\end{scope}
\begin{scope}[spy using outlines={magnification=4, size=1cm, connect spies}, shift={(2.5cm,0)}]
\draw[green] (0:0) circle[radius=1];
\spy[red, circle] on (30:1)
in node at (0,0);
\end{scope}
\end{tikzpicture}
\end{document}
Third, working MWE (explicit transformation to coordinates) and expected result of the two MWEs above:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{spy}
\begin{document}
\begin{tikzpicture}[spy using outlines={magnification=4, size=1cm, connect spies}]
\draw[green] (0:0) circle[radius=1];
\spy[black!25] on (30:1)
in node at (0,0);
\draw[green] ([shift={(2.5cm,0)}]0:0) circle[radius=1];
\spy[red, circle] on ([shift={(2.5cm,0)}]30:1)
in node at ([shift={(2.5cm,0)}]0,0);
\end{tikzpicture}
\end{document}
Brief outline of the bug
I noticed that nodes and/or magnifications created with the
\spy
macro provided by thespy
library do not adhere to scoped transformations. If the transformations are defined explicitly the coordinates in the\spy
macro, the transformation is applied correctly.(PGF Version: 2021/05/15 v3.1.9a)
Minimal working example (MWE)
First MWE (shifted
scope
withinspy scope
):Obviously, spy nodes and magnified paths are not affected by scoped transformation.
Second MWE (
spy scope
only applied toscope
s):Third, working MWE (explicit transformation to coordinates) and expected result of the two MWEs above: