I am having trouble using \spy
on a scaled tikzpicture. Example code:
\documentclass[border=0.5mm]{standalone}
\usepackage{tikz}
%\usepackage{tikzscale}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{spy,backgrounds}
\begin{document}
\begin{tikzpicture}[scale=0.75, every node/.style={scale=0.75},
spy using outlines={circle, magnification=3, connect spies},
]
\begin{axis}
\addplot+[thick, domain=-10:10, samples=20] {10*x^7};
\spy[black,size=2cm] on (1.4,2) in node [fill=white] at (4,1.5);
\end{axis}
\end{tikzpicture}
\end{document}
There are two things I want to change:
The region of the plot being magnified and the output of that magnification doesn't account for the scale of the tikzpicture (see output above). The culprit seems to be
every node/.style={scale=0.75}
. I tried using \scalebox{0.75}{...} around the whole tikzpicture, but it doesn't seem to change anything, nor does putting spy in a separate scope. This post seems relevant although the tikzpicture isn't been scaled in that example.If possible, I want the magnified region to show the curve 10x^7 without marks:
\addplot+[no marks, thick, domain=-10:10, samples=20] {10*x^7};
while the main panel should display the same curve with marks:
\addplot+[thick, domain=-10:10, samples=20] {10*x^7};
I have tried fiddling around with scope and pgfonlayer, but I can't seem to achieve something like the above. No matter the ordering of \addplot and \spy, the spy region will always be taken on the top layer it seems.
edit: My idea with scope is that I should be able to do something like
\begin{tikzpicture}[scale=0.75, every node/.style={scale=0.75},
spy using outlines={circle, magnification=3, connect spies},
]
\begin{scope}
\begin{axis}
\addplot+[thick, domain=-10:10, samples=20] {10*x^7};
\end{axis}
\end{scope}
\begin{scope}
\begin{axis}
\addplot+[no marks, thick, domain=-10:10, samples=20] {10*x^7};
\spy[black,size=2cm] on (1.4,2) in node [fill=white] at (4,1.5);
\end{axis}
\end{scope}
\end{tikzpicture}
There should be two figures superimposed on top of each other, with spy pointing to something different than what appears in the main panel. But the above apparently does nothing.