# Using tikzlibrary spy without magnifying line width and/or mark size

I am having two set of data and am trying to create an inset to show, where they differ. Therefore, it does not help me to simply magnify the area in a "canvas style" thus magnifying also mark sizes and linewidths but I would rather keep the latter two the same as in the original picture. Does anybody know a workaround? Thanks

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{spy}

\pagestyle{empty}
\begin{document}

\begin{tikzpicture}[spy using outlines=
{circle, magnification=10, connect spies}]

\begin{semilogyaxis}[
scale only axis,
width=6cm,
height=4.5cm,
xmin=-3, xmax=3,
ymin=1e-11, ymax=1e-01,
yminorticks=true,
axis on top]

color=green,
only marks,
mark=x, clip marker paths=true,
mark options={solid}]
coordinates{
(1.60852,6.13283e-05)(1.62527,6.78766e-05)(1.64203,7.16948e-05)(1.65879,7.09775e-05)(1.67554,6.64539e-05)(1.6923,6.0881e-05)(1.70905,5.65543e-05)(1.72581,5.32983e-05)(1.74256,4.89298e-05)(1.75932,4.17484e-05)(1.77607,3.27146e-05)(1.79283,2.49779e-05)(1.80958,2.06858e-05)(1.82634,1.84003e-05)(1.84309,1.49936e-05)(1.85985,1.04606e-05)(1.87661,8.34593e-06)(1.89336,9.58471e-06)(1.91012,9.76351e-06)(1.92687,6.34117e-06)(1.94363,2.77806e-06)(1.96038,1.74742e-06)(1.97714,2.82344e-06)(1.99389,3.65428e-06)(2.01065,4.17071e-06)(2.0274,2.0308e-06)(2.04416,4.41266e-07)(2.06092,3.22697e-06)(2.07767,8.75464e-06)(2.09443,9.65132e-06)(2.11118,2.4596e-06)(2.12794,1.68688e-05)(2.14469,0.0369094)(2.16145,8.18512e-05)(2.1782,7.60426e-06)(2.19496,4.54191e-07)(2.21171,1.32399e-06)(2.22847,1.89883e-06)(2.24522,1.44121e-06)(2.26198,6.10898e-07)(2.27874,8.34218e-08)(2.29549,2.48243e-07)(2.31225,4.85005e-07)(2.329,3.81316e-07)(2.34576,6.46304e-08)(2.36251,9.62666e-08)(2.37927,3.36753e-07)(2.39602,2.88187e-07)(2.41278,7.51928e-08)(2.42953,1.27397e-08)(2.44629,8.43959e-08)(2.46304,1.24876e-07)(2.4798,8.67822e-08)(2.49656,3.41846e-08)(2.51331,2.77954e-08)(2.53007,6.15079e-08)(2.54682,8.5494e-08)(2.56358,6.64095e-08)(2.58033,2.22405e-08)
};

color=blue,
solid]
coordinates{
(1.84938,1.30191e-05)(1.85147,1.24146e-05)(1.85357,1.18242e-05)(1.85566,1.12571e-05)(1.85776,1.07224e-05)(1.85985,1.02289e-05)(1.86194,9.78453e-06)(1.86404,9.39637e-06)(1.86613,9.07009e-06)(1.86823,8.80985e-06)(1.87032,8.61807e-06)(1.87242,8.4953e-06)(1.87451,8.44012e-06)(1.87661,8.4491e-06)(1.8787,8.51687e-06)(1.88079,8.63625e-06)(1.88289,8.79835e-06)(1.88498,8.99292e-06)(1.88708,9.20857e-06)(1.88917,9.43317e-06)(1.89127,9.65423e-06)(1.89336,9.85928e-06)(1.89546,1.00364e-05)(1.89755,1.01744e-05)(1.89964,1.02635e-05)(1.90174,1.02956e-05)(1.90383,1.02643e-05)(1.90593,1.01655e-05)(1.90802,9.99744e-06)(1.91012,9.76053e-06)(1.91221,9.45755e-06)(1.91431,9.09343e-06)(1.9164,8.675e-06)(1.91849,8.21075e-06)(1.92059,7.7104e-06)(1.92268,7.18453e-06)(1.92478,6.6441e-06)(1.92687,6.10007e-06)(1.92897,5.56291e-06)(1.93106,5.04223e-06)(1.93316,4.54651e-06)(1.93525,4.08287e-06)(1.93734,3.65687e-06)(1.93944,3.27255e-06)(1.94153,2.93248e-06)(1.94363,2.63793e-06)(1.94572,2.38896e-06)(1.94782,2.18482e-06)(1.94991,2.02432e-06)(1.952,1.90591e-06)(1.9541,1.82782e-06)(1.95619,1.78861e-06)(1.95829,1.78716e-06)(1.96038,1.82173e-06)(1.96248,1.89056e-06)(1.96457,1.99278e-06)(1.96667,2.12518e-06)(1.96876,2.28247e-06)(1.97085,2.46321e-06)(1.97295,2.65945e-06)(1.97504,2.8575e-06)(1.97714,3.06279e-06)(1.97923,3.2508e-06)(1.98133,3.41339e-06)(1.98342,3.57804e-06)(1.98552,3.65166e-06)(1.98761,3.79048e-06)(1.9897,3.74879e-06)(1.9918,3.91375e-06)(1.99389,3.76293e-06)(1.99599,3.71475e-06)(1.99808,3.87484e-06)(2.00018,3.92901e-06)(2.00227,4.178e-06)(2.00437,4.24233e-06)(2.00646,4.22731e-06)(2.00855,4.14918e-06)(2.01065,4.01573e-06)(2.01274,3.83296e-06)(2.01484,3.60685e-06)(2.01693,3.34385e-06)(2.01903,3.05116e-06)(2.02112,2.73675e-06)(2.02322,2.40927e-06)(2.02531,2.07799e-06)(2.0274,1.75262e-06)(2.0295,1.44312e-06)(2.03159,1.15948e-06)(2.03369,9.11526e-07)(2.03578,7.0866e-07)(2.03788,5.59614e-07)(2.03997,4.72219e-07)(2.04207,4.53168e-07)(2.04416,5.07796e-07)(2.04625,6.39886e-07)(2.04835,8.51495e-07)(2.05044,1.14281e-06)(2.05254,1.51206e-06)(2.05463,1.95543e-06)(2.05673,2.46705e-06)(2.05882,3.03904e-06)(2.06092,3.66158e-06)(2.06301,4.323e-06)(2.0651,5.01004e-06)(2.0672,5.70797e-06)(2.06929,6.40096e-06)(2.07139,7.07229e-06)(2.07348,7.70479e-06)(2.07558,8.28118e-06)(2.07767,8.78445e-06)(2.07976,9.19836e-06)(2.08186,9.50782e-06)(2.08395,9.69939e-06)(2.08605,9.76175e-06)(2.08814,9.68615e-06)(2.09024,9.4669e-06)(2.09233,9.10192e-06)(2.09443,8.59317e-06)(2.09652,7.94732e-06)(2.09861,7.17635e-06)(2.10071,6.29829e-06)(2.1028,5.33825e-06)(2.1049,4.32966e-06)(2.10699,3.31601e-06)(2.10909,2.35333e-06)(2.11118,1.51382e-06)(2.11328,8.91237e-07)(2.11537,6.09225e-07)(2.11746,8.34295e-07)(2.11956,1.79686e-06)(2.12165,3.82617e-06)(2.12375,7.41074e-06)(2.12584,1.33072e-05)(2.12794,2.27472e-05)(2.13003,3.7857e-05)(2.13213,6.2577e-05)(2.13422,0.000104901)(2.13631,0.000183099)(2.13841,0.000346694)(2.1405,0.000770869)(2.1426,0.00247743)(2.14469,0.0346725)(2.14679,0.0135714)(2.14888,0.00204092)(2.15098,0.000789018)(2.15307,0.000411883)(2.15516,0.000248454)(2.15726,0.000162664)(2.15935,0.000111989)(2.16145,7.95987e-05)(2.16354,5.77251e-05)(2.16564,4.23617e-05)(2.16773,3.12647e-05)(2.16983,2.30911e-05)(2.17192,1.69936e-05)(2.17401,1.24127e-05)(2.17611,8.96461e-06)(2.1782,6.37723e-06)(2.1803,4.45205e-06)(2.18239,3.04056e-06)(2.18449,2.02931e-06)(2.18658,1.33006e-06)(2.18868,8.73189e-07)(2.19077,6.03157e-07)(2.19286,4.75303e-07)(2.19496,4.53544e-07)(2.19705,5.08686e-07)(2.19915,6.1714e-07)(2.20124,7.59934e-07)(2.20334,9.21937e-07)(2.20543,1.09122e-06)(2.20752,1.25855e-06)(2.20962,1.41693e-06)(2.21171,1.56123e-06)(2.21381,1.68787e-06)(2.2159,1.79456e-06)(2.218,1.88003e-06)(2.22009,1.94383e-06)(2.22219,1.98616e-06)(2.22428,2.00771e-06)(2.22637,2.00954e-06)(2.22847,1.99297e-06)(2.23056,1.95951e-06)(2.23266,1.91076e-06)(2.23475,1.84839e-06)(2.23685,1.77408e-06)(2.23894,1.68953e-06)(2.24104,1.59639e-06)(2.24313,1.49628e-06)(2.24522,1.39079e-06)(2.24732,1.28146e-06)(2.24941,1.1698e-06)(2.25151,1.05724e-06)(2.2536,9.45213e-07)(2.2557,8.35071e-07)(2.25779,7.28129e-07)(2.25989,6.25636e-07)(2.26198,5.28777e-07)(2.26407,4.38655e-07)(2.26617,3.56282e-07)(2.26826,2.82563e-07)(2.27036,2.18282e-07)(2.27245,1.6409e-07)(2.27455,1.20492e-07)(2.27664,8.78404e-08)(2.27874,6.63308e-08)(2.28083,5.60087e-08)(2.28292,5.67917e-08)(2.28502,6.85251e-08)(2.28711,9.11319e-08)(2.28921,1.25176e-07)(2.2913,1.83365e-07)(2.2934,2.35926e-07)(2.29549,3.00471e-07)(2.29759,3.52233e-07)(2.29968,3.75768e-07)(2.30177,4.23818e-07)(2.30387,4.44905e-07)(2.30596,4.73498e-07)(2.30806,4.86677e-07)(2.31015,5.00881e-07)(2.31225,5.05618e-07)(2.31434,5.06775e-07)(2.31644,5.02347e-07)(2.31853,4.91622e-07)(2.32062,4.75873e-07)(2.32272,4.5387e-07)(2.32481,4.26127e-07)(2.32691,3.93243e-07)(2.329,3.55609e-07)(2.3311,3.14355e-07)(2.33319,2.70807e-07)(2.33528,2.26376e-07)(2.33738,1.82719e-07)(2.33947,1.41526e-07)(2.34157,1.04383e-07)(2.34366,7.27429e-08)(2.34576,4.7825e-08)(2.34785,3.05318e-08)(2.34995,2.14156e-08)(2.35204,2.06542e-08)(2.35413,2.80435e-08)(2.35623,4.30203e-08)(2.35832,6.47028e-08)(2.36042,9.19422e-08)(2.36251,1.23388e-07)(2.36461,1.57559e-07)(2.3667,1.92918e-07)(2.3688,2.2794e-07)(2.37089,2.61182e-07)(2.37298,2.91342e-07)(2.37508,3.17301e-07)(2.37717,3.38164e-07)(2.37927,3.53282e-07)(2.38136,3.62261e-07)(2.38346,3.6496e-07)(2.38555,3.61483e-07)(2.38765,3.52156e-07)(2.38974,3.37494e-07)(2.39183,3.18177e-07)(2.39393,2.95001e-07)(2.39602,2.68848e-07)(2.39812,2.40642e-07)(2.40021,2.11312e-07)(2.40231,1.81763e-07)(2.4044,1.52838e-07)(2.4065,1.25302e-07)(2.40859,9.98169e-08)(2.41068,7.69271e-08)(2.41278,5.70548e-08)(2.41487,4.04942e-08)(2.41697,2.74137e-08)(2.41906,1.78614e-08)(2.42116,1.17752e-08)(2.42325,8.99388e-09)(2.42535,9.27207e-09)(2.42744,1.22952e-08)(2.42953,1.76959e-08)(2.43163,2.50697e-08)(2.43372,3.39908e-08)(2.43582,4.40264e-08)(2.43791,5.47486e-08)(2.44001,6.57463e-08)(2.4421,7.66395e-08)(2.4442,8.7088e-08)(2.44629,9.67897e-08)(2.44838,1.05492e-07)(2.45048,1.12998e-07)(2.45257,1.1915e-07)(2.45467,1.23846e-07)(2.45676,1.27032e-07)(2.45886,1.2869e-07)(2.46095,1.2885e-07)(2.46304,1.27572e-07)(2.46514,1.24951e-07)(2.46723,1.21107e-07)(2.46933,1.1618e-07)(2.47142,1.10331e-07)(2.47352,1.03731e-07)(2.47561,9.65601e-08)(2.47771,8.90023e-08)(2.4798,8.12406e-08)(2.48189,7.34538e-08)(2.48399,6.58129e-08)(2.48608,5.84775e-08)(2.48818,5.1593e-08)(2.49027,4.52885e-08)(2.49237,3.96746e-08)(2.49446,3.48419e-08)(2.49656,3.08605e-08)(2.49865,2.77788e-08)(2.50074,2.56242e-08)(2.50284,2.44032e-08)(2.50493,2.41019e-08)(2.50703,2.46878e-08)(2.50912,2.61106e-08)(2.51122,2.83041e-08)(2.51331,3.11882e-08)(2.51541,3.46707e-08)(2.5175,3.86495e-08)(2.51959,4.30152e-08)(2.52169,4.76529e-08)(2.52378,5.24448e-08)(2.52588,5.72723e-08)(2.52797,6.20186e-08)(2.53007,6.65706e-08)(2.53216,7.08209e-08)(2.53426,7.46701e-08)(2.53635,7.80281e-08)(2.53844,8.0816e-08)(2.54054,8.29674e-08)(2.54263,8.44292e-08)(2.54473,8.51629e-08)(2.54682,8.51451e-08)(2.54892,8.43673e-08)(2.55101,8.28367e-08)(2.55311,8.05755e-08)(2.5552,7.76205e-08)(2.55729,7.40223e-08)(2.55939,6.98448e-08)
};

\coordinate (spypointthree) at (axis cs:2.14469,0.0346725);
\coordinate (spyviewerthree) at (axis cs:-1,1e-05);
\spy[size=2cm] on (spypointthree) in node [fill=white] at (spyviewerthree);
\end{semilogyaxis}
\end{tikzpicture}

\end{document}


-
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). – doncherry Jun 8 '12 at 9:00
pgfplots loads tikz. I remove the call to tikz and I added the picture. – Alain Matthes Jun 8 '12 at 9:02
Thanks a lot :) - didnt know how exactly to do this – Julia Jun 8 '12 at 9:10
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – Tobi Sep 15 '13 at 15:22

I apologize for this solution beforehand; this is not a clean solution.

Why is the magnified part even enhanced in that way? (Well, it's the spy library after all!)

The PGF/TikZ manual[section 49.1 “Magnifying a Part of a Picture”] describes:

Note that this magnication uses what is called a canvas transformation in this manual: Everything is magnied, including line width and text.

Great! What does the manual[section 68.4 “Coordinate Versus Canvas Transformations”] have to say about “canvas transformation”?

[…] Whereas a scaling by a factor of, say, 2 of the canvas causes everything to be scaled by this factor (including the thickness of lines and text), a scaling of two in the coordinate system causes only the coordinates to be scaled, but not the line width nor text.

By default, all transformations only apply to the coordinate transformation system. However, using the command \pgflowlevel it is possible to apply a transformation to the canvas.

Coordinate transformations are often preferable over canvas transformations.

You don't say?
Section 22.4 “Canvas Transformations” describes a TikZ key to explicitly use the canvas transformations, but no way to explicitly not use it and to use the crucial coordinate transformation instead.

I have only found a very manual way to archieve this.
First I have defined four macros:

• The first one, \myplots, is just a placeholder for the plots. We need them twice, first for the actual plot, and a second time for the part that is spied on. The coordinate-ish spying is done via a scale around key.
• The second one is just the factor that the peak gets magnified (called \spyfactor). We want that factor not to be hard-coded because we need it to calculate the coordinate that is to be scaled around. (TikZ calc library is needed for this.)
• There was a problem when I tried to use the already declared coordinate/node spypoint and spyviewer inside the scope's optional argument:

No shape named spyviewer is known.
No shape named spypoint is known.


Therefore, I defined yet another two very simple macros that just hold the coordinates for the spied-on and the spied to coordinates.

The circles around those two coordinates are now nodes with a minimum size. The line between those circles is now a drawn edge.

The actual magnified part is a re-drawn and clipped part of the actual part.

The point that we scale around is f  ²/(f  ²-1) times on the line from the spied-to to the spied-on point. Or in TikZ:

scale around={\spyfactor:($(\spyviewer)!\spyfactor^2/(\spyfactor^2-1)!(\spypoint)$)}


   f       f²/(f²-1)
———————————————————————
2    4/ 3 = 1.3333…
3    9/ 8 = 1.125
√10   10/ 9 = 1.1111…
4   16/15 = 1.0666…
⁞      ⁞       ⁞


Some thoughts:

• The clip circle's radius is reduced by the half of the line width so that no part of the magnified picture is on the “magnifying glass”.
• The magnification factor (which is just a scale but as a canvas transformation) is not the same as the coordination transformation. In fact it is

 <magnifying scale> = <coordinate scale>²


This is not very surprising, because when we scale two times in x direction and two times in y direction the result is four times as big.

## MWE

\documentclass[border=5pt,tikz]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{spy,calc}
\newcommand*\myplots[1][]{
color=green,
only marks,
mark=x, clip marker paths=true,
mark options=solid]
coordinates {(1.60852,6.13283e-05)(1.62527,6.78766e-05)(1.64203,7.16948e-05)(1.65879,7.09775e-05)(1.67554,6.64539e-05)(1.6923,6.0881e-05)(1.70905,5.65543e-05)(1.72581,5.32983e-05)(1.74256,4.89298e-05)(1.75932,4.17484e-05)(1.77607,3.27146e-05)(1.79283,2.49779e-05)(1.80958,2.06858e-05)(1.82634,1.84003e-05)(1.84309,1.49936e-05)(1.85985,1.04606e-05)(1.87661,8.34593e-06)(1.89336,9.58471e-06)(1.91012,9.76351e-06)(1.92687,6.34117e-06)(1.94363,2.77806e-06)(1.96038,1.74742e-06)(1.97714,2.82344e-06)(1.99389,3.65428e-06)(2.01065,4.17071e-06)(2.0274,2.0308e-06)(2.04416,4.41266e-07)(2.06092,3.22697e-06)(2.07767,8.75464e-06)(2.09443,9.65132e-06)(2.11118,2.4596e-06)(2.12794,1.68688e-05)(2.14469,0.0369094)(2.16145,8.18512e-05)(2.1782,7.60426e-06)(2.19496,4.54191e-07)(2.21171,1.32399e-06)(2.22847,1.89883e-06)(2.24522,1.44121e-06)(2.26198,6.10898e-07)(2.27874,8.34218e-08)(2.29549,2.48243e-07)(2.31225,4.85005e-07)(2.329,3.81316e-07)(2.34576,6.46304e-08)(2.36251,9.62666e-08)(2.37927,3.36753e-07)(2.39602,2.88187e-07)(2.41278,7.51928e-08)(2.42953,1.27397e-08)(2.44629,8.43959e-08)(2.46304,1.24876e-07)(2.4798,8.67822e-08)(2.49656,3.41846e-08)(2.51331,2.77954e-08)(2.53007,6.15079e-08)(2.54682,8.5494e-08)(2.56358,6.64095e-08)(2.58033,2.22405e-08)};
color=blue,
solid]
coordinates{(1.84938,1.30191e-05)(1.85147,1.24146e-05)(1.85357,1.18242e-05)(1.85566,1.12571e-05)(1.85776,1.07224e-05)(1.85985,1.02289e-05)(1.86194,9.78453e-06)(1.86404,9.39637e-06)(1.86613,9.07009e-06)(1.86823,8.80985e-06)(1.87032,8.61807e-06)(1.87242,8.4953e-06)(1.87451,8.44012e-06)(1.87661,8.4491e-06)(1.8787,8.51687e-06)(1.88079,8.63625e-06)(1.88289,8.79835e-06)(1.88498,8.99292e-06)(1.88708,9.20857e-06)(1.88917,9.43317e-06)(1.89127,9.65423e-06)(1.89336,9.85928e-06)(1.89546,1.00364e-05)(1.89755,1.01744e-05)(1.89964,1.02635e-05)(1.90174,1.02956e-05)(1.90383,1.02643e-05)(1.90593,1.01655e-05)(1.90802,9.99744e-06)(1.91012,9.76053e-06)(1.91221,9.45755e-06)(1.91431,9.09343e-06)(1.9164,8.675e-06)(1.91849,8.21075e-06)(1.92059,7.7104e-06)(1.92268,7.18453e-06)(1.92478,6.6441e-06)(1.92687,6.10007e-06)(1.92897,5.56291e-06)(1.93106,5.04223e-06)(1.93316,4.54651e-06)(1.93525,4.08287e-06)(1.93734,3.65687e-06)(1.93944,3.27255e-06)(1.94153,2.93248e-06)(1.94363,2.63793e-06)(1.94572,2.38896e-06)(1.94782,2.18482e-06)(1.94991,2.02432e-06)(1.952,1.90591e-06)(1.9541,1.82782e-06)(1.95619,1.78861e-06)(1.95829,1.78716e-06)(1.96038,1.82173e-06)(1.96248,1.89056e-06)(1.96457,1.99278e-06)(1.96667,2.12518e-06)(1.96876,2.28247e-06)(1.97085,2.46321e-06)(1.97295,2.65945e-06)(1.97504,2.8575e-06)(1.97714,3.06279e-06)(1.97923,3.2508e-06)(1.98133,3.41339e-06)(1.98342,3.57804e-06)(1.98552,3.65166e-06)(1.98761,3.79048e-06)(1.9897,3.74879e-06)(1.9918,3.91375e-06)(1.99389,3.76293e-06)(1.99599,3.71475e-06)(1.99808,3.87484e-06)(2.00018,3.92901e-06)(2.00227,4.178e-06)(2.00437,4.24233e-06)(2.00646,4.22731e-06)(2.00855,4.14918e-06)(2.01065,4.01573e-06)(2.01274,3.83296e-06)(2.01484,3.60685e-06)(2.01693,3.34385e-06)(2.01903,3.05116e-06)(2.02112,2.73675e-06)(2.02322,2.40927e-06)(2.02531,2.07799e-06)(2.0274,1.75262e-06)(2.0295,1.44312e-06)(2.03159,1.15948e-06)(2.03369,9.11526e-07)(2.03578,7.0866e-07)(2.03788,5.59614e-07)(2.03997,4.72219e-07)(2.04207,4.53168e-07)(2.04416,5.07796e-07)(2.04625,6.39886e-07)(2.04835,8.51495e-07)(2.05044,1.14281e-06)(2.05254,1.51206e-06)(2.05463,1.95543e-06)(2.05673,2.46705e-06)(2.05882,3.03904e-06)(2.06092,3.66158e-06)(2.06301,4.323e-06)(2.0651,5.01004e-06)(2.0672,5.70797e-06)(2.06929,6.40096e-06)(2.07139,7.07229e-06)(2.07348,7.70479e-06)(2.07558,8.28118e-06)(2.07767,8.78445e-06)(2.07976,9.19836e-06)(2.08186,9.50782e-06)(2.08395,9.69939e-06)(2.08605,9.76175e-06)(2.08814,9.68615e-06)(2.09024,9.4669e-06)(2.09233,9.10192e-06)(2.09443,8.59317e-06)(2.09652,7.94732e-06)(2.09861,7.17635e-06)(2.10071,6.29829e-06)(2.1028,5.33825e-06)(2.1049,4.32966e-06)(2.10699,3.31601e-06)(2.10909,2.35333e-06)(2.11118,1.51382e-06)(2.11328,8.91237e-07)(2.11537,6.09225e-07)(2.11746,8.34295e-07)(2.11956,1.79686e-06)(2.12165,3.82617e-06)(2.12375,7.41074e-06)(2.12584,1.33072e-05)(2.12794,2.27472e-05)(2.13003,3.7857e-05)(2.13213,6.2577e-05)(2.13422,0.000104901)(2.13631,0.000183099)(2.13841,0.000346694)(2.1405,0.000770869)(2.1426,0.00247743)(2.14469,0.0346725)(2.14679,0.0135714)(2.14888,0.00204092)(2.15098,0.000789018)(2.15307,0.000411883)(2.15516,0.000248454)(2.15726,0.000162664)(2.15935,0.000111989)(2.16145,7.95987e-05)(2.16354,5.77251e-05)(2.16564,4.23617e-05)(2.16773,3.12647e-05)(2.16983,2.30911e-05)(2.17192,1.69936e-05)(2.17401,1.24127e-05)(2.17611,8.96461e-06)(2.1782,6.37723e-06)(2.1803,4.45205e-06)(2.18239,3.04056e-06)(2.18449,2.02931e-06)(2.18658,1.33006e-06)(2.18868,8.73189e-07)(2.19077,6.03157e-07)(2.19286,4.75303e-07)(2.19496,4.53544e-07)(2.19705,5.08686e-07)(2.19915,6.1714e-07)(2.20124,7.59934e-07)(2.20334,9.21937e-07)(2.20543,1.09122e-06)(2.20752,1.25855e-06)(2.20962,1.41693e-06)(2.21171,1.56123e-06)(2.21381,1.68787e-06)(2.2159,1.79456e-06)(2.218,1.88003e-06)(2.22009,1.94383e-06)(2.22219,1.98616e-06)(2.22428,2.00771e-06)(2.22637,2.00954e-06)(2.22847,1.99297e-06)(2.23056,1.95951e-06)(2.23266,1.91076e-06)(2.23475,1.84839e-06)(2.23685,1.77408e-06)(2.23894,1.68953e-06)(2.24104,1.59639e-06)(2.24313,1.49628e-06)(2.24522,1.39079e-06)(2.24732,1.28146e-06)(2.24941,1.1698e-06)(2.25151,1.05724e-06)(2.2536,9.45213e-07)(2.2557,8.35071e-07)(2.25779,7.28129e-07)(2.25989,6.25636e-07)(2.26198,5.28777e-07)(2.26407,4.38655e-07)(2.26617,3.56282e-07)(2.26826,2.82563e-07)(2.27036,2.18282e-07)(2.27245,1.6409e-07)(2.27455,1.20492e-07)(2.27664,8.78404e-08)(2.27874,6.63308e-08)(2.28083,5.60087e-08)(2.28292,5.67917e-08)(2.28502,6.85251e-08)(2.28711,9.11319e-08)(2.28921,1.25176e-07)(2.2913,1.83365e-07)(2.2934,2.35926e-07)(2.29549,3.00471e-07)(2.29759,3.52233e-07)(2.29968,3.75768e-07)(2.30177,4.23818e-07)(2.30387,4.44905e-07)(2.30596,4.73498e-07)(2.30806,4.86677e-07)(2.31015,5.00881e-07)(2.31225,5.05618e-07)(2.31434,5.06775e-07)(2.31644,5.02347e-07)(2.31853,4.91622e-07)(2.32062,4.75873e-07)(2.32272,4.5387e-07)(2.32481,4.26127e-07)(2.32691,3.93243e-07)(2.329,3.55609e-07)(2.3311,3.14355e-07)(2.33319,2.70807e-07)(2.33528,2.26376e-07)(2.33738,1.82719e-07)(2.33947,1.41526e-07)(2.34157,1.04383e-07)(2.34366,7.27429e-08)(2.34576,4.7825e-08)(2.34785,3.05318e-08)(2.34995,2.14156e-08)(2.35204,2.06542e-08)(2.35413,2.80435e-08)(2.35623,4.30203e-08)(2.35832,6.47028e-08)(2.36042,9.19422e-08)(2.36251,1.23388e-07)(2.36461,1.57559e-07)(2.3667,1.92918e-07)(2.3688,2.2794e-07)(2.37089,2.61182e-07)(2.37298,2.91342e-07)(2.37508,3.17301e-07)(2.37717,3.38164e-07)(2.37927,3.53282e-07)(2.38136,3.62261e-07)(2.38346,3.6496e-07)(2.38555,3.61483e-07)(2.38765,3.52156e-07)(2.38974,3.37494e-07)(2.39183,3.18177e-07)(2.39393,2.95001e-07)(2.39602,2.68848e-07)(2.39812,2.40642e-07)(2.40021,2.11312e-07)(2.40231,1.81763e-07)(2.4044,1.52838e-07)(2.4065,1.25302e-07)(2.40859,9.98169e-08)(2.41068,7.69271e-08)(2.41278,5.70548e-08)(2.41487,4.04942e-08)(2.41697,2.74137e-08)(2.41906,1.78614e-08)(2.42116,1.17752e-08)(2.42325,8.99388e-09)(2.42535,9.27207e-09)(2.42744,1.22952e-08)(2.42953,1.76959e-08)(2.43163,2.50697e-08)(2.43372,3.39908e-08)(2.43582,4.40264e-08)(2.43791,5.47486e-08)(2.44001,6.57463e-08)(2.4421,7.66395e-08)(2.4442,8.7088e-08)(2.44629,9.67897e-08)(2.44838,1.05492e-07)(2.45048,1.12998e-07)(2.45257,1.1915e-07)(2.45467,1.23846e-07)(2.45676,1.27032e-07)(2.45886,1.2869e-07)(2.46095,1.2885e-07)(2.46304,1.27572e-07)(2.46514,1.24951e-07)(2.46723,1.21107e-07)(2.46933,1.1618e-07)(2.47142,1.10331e-07)(2.47352,1.03731e-07)(2.47561,9.65601e-08)(2.47771,8.90023e-08)(2.4798,8.12406e-08)(2.48189,7.34538e-08)(2.48399,6.58129e-08)(2.48608,5.84775e-08)(2.48818,5.1593e-08)(2.49027,4.52885e-08)(2.49237,3.96746e-08)(2.49446,3.48419e-08)(2.49656,3.08605e-08)(2.49865,2.77788e-08)(2.50074,2.56242e-08)(2.50284,2.44032e-08)(2.50493,2.41019e-08)(2.50703,2.46878e-08)(2.50912,2.61106e-08)(2.51122,2.83041e-08)(2.51331,3.11882e-08)(2.51541,3.46707e-08)(2.5175,3.86495e-08)(2.51959,4.30152e-08)(2.52169,4.76529e-08)(2.52378,5.24448e-08)(2.52588,5.72723e-08)(2.52797,6.20186e-08)(2.53007,6.65706e-08)(2.53216,7.08209e-08)(2.53426,7.46701e-08)(2.53635,7.80281e-08)(2.53844,8.0816e-08)(2.54054,8.29674e-08)(2.54263,8.44292e-08)(2.54473,8.51629e-08)(2.54682,8.51451e-08)(2.54892,8.43673e-08)(2.55101,8.28367e-08)(2.55311,8.05755e-08)(2.5552,7.76205e-08)(2.55729,7.40223e-08)(2.55939,6.98448e-08)};
}
\newcommand*\spyfactor{3.1622776601683793319988935444327}
\newcommand*\spypoint{axis cs:2.14469,0.0346725}
\newcommand*\spyviewer{axis cs:-1,1e-05}
\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}[
scale only axis,
width=6cm,
height=4.5cm,
xmin=-3, xmax=3,
ymin=1e-11, ymax=1e-01,
yminorticks=true,
axis on top]
\myplots
\node[very thin, circle, draw, minimum size=.2cm, inner sep=0pt] (spypoint) at (\spypoint) {};
\node[circle, draw, minimum size=2cm, inner sep=0pt] (spyviewer) at (\spyviewer) {};
\draw (spypoint) edge (spyviewer);
\begin{scope}
\clip (spyviewer) circle (1cm-.5\pgflinewidth);
\pgfmathparse{\spyfactor^2/(\spyfactor-1)}
\begin{scope}[scale around={\spyfactor:($(\spyviewer)!\spyfactor^2/(\spyfactor^2-1)!(\spypoint)$)}]
\myplots
\end{scope}
\end{scope}

% debug
\fill[gray] ($(\spyviewer)!\spyfactor^2/(\spyfactor^2-1)!(\spypoint)$) circle (.5pt) node [below=-3pt,font=\fontsize{4}{4.8}\selectfont] {\scalebox{.7}{\parbox{.2cm}{scale-around point}}};
\end{semilogyaxis}
\end{tikzpicture}
\end{document}


## Output

-
You only gave the relevant digits of \spyfactor :) – Tom Bombadil Oct 7 '12 at 13:01
I can't get the same output, my spyviewer is completely blank :\ – joaocandre Jul 17 '13 at 14:50
@joaocandre Have you changed anything at the example from my answer? The given solution is not very flexible, you will need to change values at a view places to get correct results. But if you didn’t change anything, it should work. Are you using an up-to-date distribution and up-to-date packages? – Qrrbrbirlbel Jul 17 '13 at 15:45

I was looking for this feature and build up another solution based on the ideas of @Qrrbrbirlbel. Seems like my solution is a little more flexible – tell me if not …

Firstly I set some parameters, like the size of the spy nodes, the zoom factors and the points I’d like to zoom. Then I define the picture as \pic and draw the original one. The next thing is the zooming. I draw the spy on node, which’s size depends on the zoom factor.

\node[spy,minimum size={\spyviewersize/\spyfactorI}] (spy-on node 1) at (spy-on 1) {};


and then the spy in node

\node[spy,minimum size=\spyviewersize] (spy-in node 1) at (spy-in 1) {};


Then I shift a copy of the original picture so that the zoomed point lies in the center of the spy in node and scale it around the point I want to zoom.

\pgfmathsetmacro\sI{1/\spyfactorI}
\begin{scope}[
shift={($\sI*(spy-in 1)-\sI*(spy-on 1)$)},
scale around={\spyfactorI:(spy-on 1)}
]
\pic
\end{scope}


Then this drawing must be clipped to fit inside the spy in node:

\begin{scope}
\clip (spy-in 1) circle (0.5*\spyviewersize-\spyonclipreduce);
% ... the zoomed scope from above ...
\end{scope}


The last thing is to connect the spy nodes

\draw [spy] (spy-on node 1) -- (spy-in node 1);


In my case I needed several zooming steps to show a parabola (the green one, the red on is just for fun at TeX.SX) becoming a line the more we zoom it in. For that I nested the above scopes in more scopes adding the second and third zooming (see the code below). After doing all the zooming I add some text showing the zoom factors.

full code

\documentclass[tikz,border=5mm]{standalone}

\usetikzlibrary{calc,positioning}

\begin{document}
\begin{tikzpicture}[
% Style for the spy nodes and the connection line
spy/.style={%
draw,blue,
line width=1pt,
circle,inner sep=0pt,
},
]
% Parameters

%% size of the spy-in nodes
\def\spyviewersize{1.25cm}

%% (line width of the spy nodes) / 2
%% we need this for clipping later
\def\spyonclipreduce{0.5pt}

%% first zoom
%%% factor
\def\spyfactorI{1.5}
%%% spy on point
\coordinate (spy-on 1) at (2.44,1);% sould be on the curve
%%% spy in point
\coordinate (spy-in 1) at (7,5);

%% second zoom
%%% factor
\def\spyfactorII{2}
%%% spy on point (last spy in point)
\coordinate (spy-on 2) at (spy-in 1);
%%% spy in point
\coordinate (spy-in 2) at ($(spy-on 2)+(1,-3.5)$);

%% third zoom
%%% factor
\def\spyfactorIII{4}
%%% spy on point (last spy in point)
\coordinate (spy-on 3) at (spy-in 2);
%%% spy in point
\coordinate (spy-in 3) at ($(spy-on 3)+(1.5,1.5)$);

%% the graph/picture
\def\pic{
%%% grid
\draw [ultra thin,step=0.2,gray] (0,0) grid (6,6);
%%% graph
\draw [line width=2pt,green!70!black] (0,0) parabola [bend at start] (6,6);
\draw [line width=2pt,red!70!black] (2,0) parabola [bend={(2.5,1)}] (3,0);
%%% axes
\draw [->] (0,0) -- (6,0) node [right] {$t$};
\draw [->] (0,0) -- (0,6) node [left] {$x$};
}

% draw the original picture
\pic

% first zoom
%% spy on node
\node[spy,minimum size={\spyviewersize/\spyfactorI}] (spy-on node 1) at (spy-on 1) {};
%% spy in node
\node[spy,minimum size=\spyviewersize] (spy-in node 1) at (spy-in 1) {};
\begin{scope}
\clip (spy-in 1) circle (0.5*\spyviewersize-\spyonclipreduce);
\pgfmathsetmacro\sI{1/\spyfactorI}
\begin{scope}[
shift={($\sI*(spy-in 1)-\sI*(spy-on 1)$)},
scale around={\spyfactorI:(spy-on 1)}
]
\pic
\end{scope}
\end{scope}
%% connect the nodes
\draw [spy] (spy-on node 1) -- (spy-in node 1);

% second zoom
%% spy on node
\node[spy,minimum size={\spyviewersize/\spyfactorII}] (spy-on node 2) at (spy-on 2) {};
%% spy in node
\node[spy,minimum size=\spyviewersize] (spy-in node 2) at (spy-in 2) {};
\begin{scope}
\clip (spy-in 2) circle (0.5*\spyviewersize-\spyonclipreduce);
\pgfmathsetmacro\sI{1/\spyfactorI}
\pgfmathsetmacro\sII{1/\spyfactorII}
\begin{scope}[
shift={($\sI*(spy-in 1)-\sI*(spy-on 1)$)},
scale around={\spyfactorI:(spy-on 1)}
]
\begin{scope}[
shift={($\sII*(spy-in 2)-\sII*(spy-on 2)$)},
scale around={\spyfactorII:(spy-on 2)}
]
\pic
\end{scope}
\end{scope}
\end{scope}
%% connect the nodes
\draw [spy] (spy-on node 2) -- (spy-in node 2);

% third zoom
%% spy on node
\node[spy,minimum size={\spyviewersize/\spyfactorIII}] (spy-on node 3) at (spy-on 3) {};
%% spy in node
\node[spy,minimum size=\spyviewersize] (spy-in node 3) at (spy-in 3) {};
\begin{scope}
\clip (spy-in 3) circle (0.5*\spyviewersize-\spyonclipreduce);
\pgfmathsetmacro\sI{1/\spyfactorI}
\pgfmathsetmacro\sII{1/\spyfactorII}
\pgfmathsetmacro\sIII{1/\spyfactorIII}
\begin{scope}[
shift={($\sI*(spy-in 1)-\sI*(spy-on 1)$)},
scale around={\spyfactorI:(spy-on 1)}
]
\begin{scope}[
shift={($\sII*(spy-in 2)-\sII*(spy-on 2)$)},
scale around={\spyfactorII:(spy-on 2)}
]
\begin{scope}[
shift={($\sIII*(spy-in 3)-\sIII*(spy-on 3)$)},
scale around={\spyfactorIII:(spy-on 3)}
]
\pic
\end{scope}
\end{scope}
\end{scope}
\end{scope}
%% connect the nodes
\draw [spy] (spy-on node 3) -- (spy-in node 3);

% print the factors
\node [above=0pt of spy-in node 1] {$\spyfactorI\times$};
\pgfmathsetmacro\spyfactor{\spyfactorI*\spyfactorII}
\node [below=0pt of spy-in node 2,align=center]
{additional: $\spyfactorII\times$\\(sum: $\spyfactor\times$)};
\pgfmathsetmacro\spyfactor{\spyfactor*\spyfactorIII}
\node [above=0pt of spy-in node 3,align=center]
{additional: $\spyfactorIII\times$\\(sum: $\spyfactor\times$)};
\end{tikzpicture}
\end{document}

-