1

I'm trying to use lualatex 0.79 (via MikTeX2.9) to produce a TikZ picture with 'spy' bubbles, but notice a problem when trying to scale the overall picture -- the spied 'bubbles' do not appear where I would expect.

Here's a sample code example:

\documentclass{article}
\usepackage{tikz}
\usepackage{tikzscale}
\usepackage{pgfplots}
\usetikzlibrary{spy}
\pgfplotsset{compat=newest}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[spy using outlines={circle, magnification=3,size=1cm, connect spies},scale=0.63,every node/.style={transform shape}]
\begin{axis}[%
domain=0:3000, restrict y to domain=-1:1,
width=4.520833in,height=3.565625in,
at={(0.758333in,0.48125in)},
scale only axis,
xmin=0,xmax=3000,
scaled y ticks = false,
ymin=-0.05,ymax=0.05,
xmajorgrids,ymajorgrids,
xlabel={x-label},
]

\coordinate (spypoint1) at (axis cs:0,0);
\coordinate (spypoint2) at (axis cs:500,0.02);

\end{axis}

\spy on (spypoint1) in node at (spypoint2);

\end{tikzpicture}
\end{figure}
\end{document}

Inclusion of 'scale=0.63,every node/.style={transform shape}' causes problems (in that the spy bubbles are not where I'd expect them to be (at coordinates given by 'spypoint1' and 'spypoint2')), while exclusion of this (i.e., with nominal scaling) is OK.

Am I going about this incorrectly? (I'd like to scale the text as well -- hence, 'scale' usage in tikzpicture, and not 'axis'.)

Any suggestions/solutions would be greatly appreciated!

Thanks,

Michael

1

You can enclose the whole tikzpicture inside of a \scalebox{<scale>}{<tikzpicture>}.

Output

figure 1

Code

\documentclass{article}
\usepackage{tikz}
\usepackage{tikzscale}
\usepackage{pgfplots}
\usetikzlibrary{spy}
\pgfplotsset{compat=newest}
\begin{document}
\begin{figure}[htbp]
\centering
\scalebox{.63}{
\begin{tikzpicture}[spy using outlines={circle, magnification=3,size=1cm, connect spies}]
\begin{axis}[%
domain=0:3000, restrict y to domain=-1:1,
width=4.520833in,height=3.565625in,
at={(0.758333in,0.48125in)},
scale only axis,
xmin=0,xmax=3000,
scaled y ticks = false,
ymin=-0.05,ymax=0.05,
xmajorgrids,ymajorgrids,
xlabel={x-label},
]

\coordinate (spypoint1) at (axis cs:0,0);
\coordinate (spypoint2) at (axis cs:500,0.02);

\end{axis}

\spy on (spypoint1) in node at (spypoint2);

\end{tikzpicture}}
\end{figure}
\end{document}

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.