使用 tikzlibrary spy 而不放大线宽和/或标记大小

使用 tikzlibrary spy 而不放大线宽和/或标记大小

我有两组数据,并试图创建一个插图来显示它们的不同之处。因此,简单地以“画布样式”放大区域(从而也放大标记大小和线宽)对我没有帮助,但我宁愿让后两者与原始图片相同。有人知道解决方法吗?谢谢

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\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]

\addplot [
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)
};

\addplot [
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}

在此处输入图片描述

答案1

我提前为这个解决方案道歉;这不是一个干净的解决方案。


为什么放大的部分还会被这样增强呢? spy(嗯,毕竟这是图书馆!)

PGF/TikZ 手册[第 49.1 节“放大图片的一部分”]描述:

请注意,这种放大使用所谓的画布变换在此手册中:所有内容均被放大,包括线宽和文本。

太棒了!手册[第 68.4 节“坐标与画布变换”]对“画布变换”有何说明?

[…] 如果将画布按一定倍数缩放,比如说,2,则所有内容都会按该倍数缩放(包括线条和文本的粗细);如果将坐标系按 2 倍缩放,则只缩放坐标,而不会缩放线宽和文本。

默认情况下,所有变换仅适用于坐标变换系统。但是,使用该命令\pgflowlevel可以将变换应用于画布。

坐标变换通常比画布变换更可取。

你不說嗎?
第 22.4 节“画布变换”描述了一个 TikZ 键,用于明确使用画布变换,但没有办法明确不是使用它并改用关键的坐标变换。


我只找到了一种非常手动的方法来实现这一点。
首先,我定义了四个宏:

  • 第一个,\myplots,只是情节的占位符。我们需要它们两次,第一次用于实际情节,第二次用于监视部分。协调-ish 监视是通过scale around密钥完成的。
  • 第二个只是峰值被放大的因子(称为\spyfactor)。我们希望该因子不是硬编码的,因为我们需要它来计算要缩放的坐标。(calc这需要 TikZ 库。)
  • spypoint当我尝试使用已声明的坐标/节点以及spyviewer范围的可选参数时出现了问题:

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

    因此,我又定义了两个非常简单的宏,它们仅保存被监视的坐标和被监视的坐标。

这两个坐标周围的圆圈现在是具有最小尺寸的节点。这两个圆圈之间的线现在是绘制的edge

实际放大的部分是实际部分重新绘制并裁剪的一部分。

我们缩放的点是F  ²/(F  ²-1) 次从被监视点到被监视点的直线。或者在 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…
    ⁞      ⁞       ⁞

一些想法:

  • 剪辑圆的半径减小了线宽的一半,以便放大的图片的任何部分都不在“放大镜”上。
  • 放大倍数(只是scale画布变换的一个功能)与坐标变换不同。事实上,它是

     <magnifying scale> = <coordinate scale>²
    

    这并不奇怪,因为当我们将规模扩大一倍时,X方向,并两次方向的结果将是原来的四倍。

平均能量损失

\documentclass[border=5pt,tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{spy,calc}
\newcommand*\myplots[1][]{
    \addplot[#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)};
    \addplot[#1,
        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}

输出

MWE编译

答案2

我一直在寻找这个功能,并根据@Qrrbrbirlbel 的想法构建了另一个解决方案。看来我的解决方案更灵活一些——如果不行请告诉我……

放大抛物线

首先我设置一些参数,比如侦探节点的大小、缩放系数和我想要缩放的点。然后我将图片定义为\pic并绘制原始图片。接下来是缩放。我绘制侦探节点,其大小取决于缩放系数。

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

然后是节点中的间谍

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

然后我移动原始图片的副本,使得放大的点位于间谍节点的中心,并围绕我想要放大的点进行缩放。

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

然后必须剪裁此绘图以适合节点中的间谍:

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

最后一件事是连接间谍节点

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

在我的例子中,我需要几个缩放步骤来显示抛物线(绿色,红色只是为了在 TeX.SX 上好玩),我们放大它越多,它就越变成一条线。为此,我将上述范围嵌套在更多范围内,并添加第二次和第三次缩放(参见下面的代码)。完成所有缩放后,我添加了一些显示缩放系数的文本。

完整代码

\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}

相关内容