我正在尝试使用 spy 来放大一个包含大量不同比例的图。但是当我放大时,图看起来并不像预期的那样。它看起来有点像素化。知道为什么吗?如何解决这个问题?
以下是我的 tex 文件:
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{every axis legend/.append style={%
cells={anchor=west}}
}
\usetikzlibrary{arrows}
\tikzset{>=stealth'}
\usetikzlibrary{spy}
\definecolor{m1_color}{HTML}{9BFF85}
\definecolor{m2_color}{HTML}{BC86D1}
\begin{document}
\begin{tikzpicture}[]
\begin{scope}[spy using outlines={rectangle, magnification=100,
width=3cm,height=4cm,connect spies}]
\begin{axis}[
legend style = {at={(1.05,1.0)}, anchor=north west},
ylabel = {$x_2$},
title = {Sets},
xlabel = {$x_1$},
width=8cm, height=8cm
]
\addplot+[
mark = {none},
red, dashed
] coordinates {
(-0.2617, -4000.0)
(-0.2617, 4000.0)
};
\addlegendentry{{}{Set}}
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(1.2, 0.2)
(1.0, 0.2)
(1.0, -8.32667268468867e-17)
(1.2, -8.32667268468867e-17)
(1.2, 0.2)
};
\addlegendentry{{}{M1}}
\addplot+[
solid, m2_color, mark=none, fill=m2_color
] coordinates {
(1.2, 0.2)
(1.0, 0.2)
(1.0, -8.32667268468867e-17)
(1.2, -8.32667268468867e-17)
(1.2, 0.2)
};
\addlegendentry{{}{M2}}
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(1.0, -0.265972863900861)
(1.0, -0.456228776570086)
(1.2, -0.438084931713062)
(1.22, -0.238084931713074)
(1.22, -0.0478290190439142)
(1.01999999999999, -0.0659728639009378)
(1.0, -0.265972863900861)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(1.0000000000000002, -0.33518225819442576)
(1.22, -0.33518225819442576)
(1.22, -0.17021742804955514)
(1.0000000000000002, -0.17021742804955514)
(1.0000000000000002, -0.33518225819442576)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(0.954377122342992, -0.522007062932457)
(0.954377122342992, -0.791111837889065)
(1.17437712234299, -0.77154673115243)
(1.21521709809561, -0.363146973626258)
(1.21521709809561, -0.0940421986695393)
(0.995217098095621, -0.113607305406173)
(0.954377122342992, -0.522007062932457)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.9664817741805576, -0.5148584453878854)
(1.2029782571950445, -0.5148584453878854)
(1.2029782571950445, -0.3472697833820113)
(0.9664817741805576, -0.3472697833820113)
(0.9664817741805576, -0.5148584453878854)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(1.20581287822866, -0.383612590977629)
(1.20581287822865, -0.0110938341341925)
(0.944972902476051, -0.0354610929819111)
(0.875265938554085, -0.732530732201572)
(0.875265938554085, -1.10504948904487)
(1.1361059143067, -1.08068223019715)
(1.20581287822866, -0.383612590977629)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.9149959296417689, -0.6220770983026074)
(1.1682512788568433, -0.6220770983026074)
(1.1682512788568433, -0.44233041239025134)
(0.9149959296417689, -0.44233041239025134)
(0.9149959296417689, -0.6220770983026074)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(0.764760989649598, -0.909164298142755)
(0.764760989649598, -1.46804479980734)
(1.09530792932417, -1.43460964660762)
(1.20470349481524, -0.340653991696946)
(1.20470349481524, 0.218226509967615)
(0.874156555140663, 0.184791356767894)
(0.764760989649598, -0.909164298142755)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.8527882198115082, -0.6808926203122335)
(1.1240182376178183, -0.6808926203122335)
(1.1240182376178183, -0.48954160843927597)
(0.8527882198115082, -0.48954160843927597)
(0.8527882198115082, -0.6808926203122335)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(1.226526145812, -0.231598483774965)
(1.22652614581199, 0.595201272436226)
(0.786583640646383, 0.54653604590246)
(0.617956509668863, -1.13973526387273)
(0.617956509668863, -1.96653502008369)
(1.0578990148345, -1.91786979354992)
(1.226526145812, -0.231598483774965)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.784698957780285, -0.7063804113578739)
(1.0750640767738906, -0.7063804113578739)
(1.0750640767738906, -0.5043198977107385)
(0.784698957780285, -0.5043198977107385)
(0.784698957780285, -0.7063804113578739)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(1.28604627305562, -0.0508065165129705)
(1.28604627305561, 1.19839631185699)
(0.677476636912518, 1.12487678718561)
(0.421303007660494, -1.43685950533463)
(0.421303007660494, -2.68606233370428)
(1.02987264380363, -2.61254280903289)
(1.28604627305562, -0.0508065165129705)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.7140609166444976, -0.7121020461361469)
(1.0246320870028167, -0.7121020461361469)
(1.0246320870028167, -0.5005380380153659)
(0.7140609166444976, -0.5005380380153659)
(0.7140609166444976, -0.7121020461361469)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(0.152696774290067, -1.83290603746247)
(0.152696774290067, -3.69428062791109)
(1.01744003968518, -3.58061565814048)
(1.40588590424132, 0.303842987420796)
(1.40588590424132, 2.16521757786986)
(0.541142638846251, 2.05155260809925)
(0.152696774290067, -1.83290603746247)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.6428507120308828, -0.7036049870229895)
(0.9745782832012801, -0.7036049870229895)
(0.9745782832012801, -0.4839955195431415)
(0.6428507120308828, -0.4839955195431415)
(0.6428507120308828, -0.7036049870229895)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(-0.216731288501042, -2.4006218767853)
(-0.216731288501042, -5.14654254776789)
(1.03645784145021, -4.96823585437409)
(1.6224076620283, 0.891262351406865)
(1.6224076620283, 3.63718302238989)
(0.369218532077098, 3.4588763289961)
(-0.216731288501042, -2.4006218767853)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.5724902133285839, -0.6857050321049143)
(0.926178731246966, -0.6857050321049143)
(0.926178731246966, -0.45830050052424487)
(0.5724902133285839, -0.45830050052424487)
(0.5724902133285839, -0.6857050321049143)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(-0.731385543277831, -3.21535547224507)
(-0.731385543277831, -7.29345816496984)
(1.10775340725152, -7.01280162568897)
(1.98612596426729, 1.7709239444688)
(1.98612596426729, 5.84902663719358)
(0.146987013737947, 5.56837009791271)
(-0.731385543277831, -3.21535547224507)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.5039197101180924, -0.6620306568311631)
(0.8803486811945415, -0.6620306568311631)
(0.8803486811945415, -0.42513703766443084)
(0.5039197101180924, -0.42513703766443084)
(0.5039197101180924, -0.6620306568311631)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(-1.46073135977482, -4.39340349345896)
(-1.46073135977482, -10.5636310108625)
(1.25678014777031, -10.1236256573403)
(2.57102862798665, 3.01885914482306)
(2.57102862798665, 9.18908666222662)
(-0.146482879558475, 8.74908130870443)
(-1.46073135977482, -4.39340349345896)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.5706309645241158, -0.5697397804548586)
(0.7077128836724133, -0.5697397804548586)
(0.7077128836724133, -0.44665551893215827)
(0.5706309645241158, -0.44665551893215827)
(0.5706309645241158, -0.5697397804548586)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(-2.51709446086107, -6.11341690682214)
(-2.51709446086107, -15.6183188492749)
(1.5146655269004, -14.9330630940092)
(3.48993729420931, 4.81965457907993)
(3.48993729420931, 14.3245565215327)
(-0.541822693552153, 13.639300766267)
(-2.51709446086107, -6.11341690682214)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.5136569864786298, -0.531430017461147)
(0.6630473317791974, -0.531430017461147)
(0.6630473317791974, -0.41744607539390693)
(0.5136569864786298, -0.41744607539390693)
(0.5136569864786298, -0.531430017461147)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(-4.07892634578856, -8.68544333206393)
(-4.07892634578856, -23.5744199014376)
(1.92810540928182, -22.5123630159944)
(4.92239294636259, 7.43051235481332)
(4.92239294636259, 22.3194889241869)
(-1.08463880870779, 21.2574320387437)
(-4.07892634578856, -8.68544333206393)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.46051398473251515, -0.4964265845072361)
(0.6213027242398067, -0.4964265845072361)
(0.6213027242398067, -0.38621236838418593)
(0.46051398473251515, -0.38621236838418593)
(0.46051398473251515, -0.4964265845072361)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(-6.43636833593232, -12.4262704179285)
(-6.43636833593232, -36.3900995019178)
(2.56495095621883, -34.7475733266099)
(7.15434183878128, 11.1463354990145)
(7.15434183878128, 35.1101645830039)
(-1.84697745336987, 33.467638407696)
(-6.43636833593232, -12.4262704179285)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.41087132628179157, -0.4644529697032833)
(0.582681487401388, -0.4644529697032833)
(0.582681487401388, -0.3550152223389401)
(0.41087132628179157, -0.3550152223389401)
(0.41087132628179157, -0.4644529697032833)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(-10.0753782861241, -17.702243488814)
(-10.0753782861241, -57.7258371471229)
(3.51533188858949, -55.1809677390287)
(10.6653582970817, 16.3192963458931)
(10.6653582970817, 56.3428900042021)
(-2.92535187763192, 53.7980205961078)
(-10.0753782861241, -17.702243488814)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.3644260293114632, -0.4353184705067951)
(0.547179965167494, -0.4353184705067951)
(0.547179965167494, -0.32479226976279224)
(0.3644260293114632, -0.32479226976279224)
(0.3644260293114632, -0.4353184705067951)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(-15.8479620008364, -24.7137875791216)
(-15.8479620008364, -94.900443483593)
(4.89277458236938, -90.9314751908562)
(16.2996472975019, 23.1372519604688)
(16.2996472975019, 93.3239078649403)
(-4.44108928570389, 89.3549395722034)
(-15.8479620008364, -24.7137875791216)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.3208941822607836, -0.40884832681838984)
(0.5147007381912148, -0.40884832681838984)
(0.5147007381912148, -0.2960245598213543)
(0.3208941822607836, -0.2960245598213543)
(0.3208941822607836, -0.40884832681838984)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(-25.3380063491957, -32.636146579462)
(-25.3380063491957, -163.72232277894)
(6.80960294914256, -157.456073735268)
(25.6320380839959, 30.7682776132649)
(25.6320380839959, 161.854453812743)
(-6.51557121434236, 155.588204769071)
(-25.3380063491957, -32.636146579462)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.28000934957894463, -0.38486583418900205)
(0.48509828220907925, -0.38486583418900205)
(0.48509828220907925, -0.268916163058924)
(0.28000934957894463, -0.268916163058924)
(0.28000934957894463, -0.38486583418900205)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(-41.7102386270898, -36.3327695153007)
(-41.7102386270898, -301.72164406616)
(9.25980580610184, -291.637601847966)
(41.8174834652703, 33.9391747437177)
(41.8174834652703, 299.328049294576)
(-9.15256096792138, 289.244007076383)
(-41.7102386270898, -36.3327695153007)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.24152276616004442, -0.363190784002575)
(0.4582066659031868, -0.363190784002575)
(0.4582066659031868, -0.24334619751797007)
(0.24152276616004442, -0.24334619751797007)
(0.24152276616004442, -0.363190784002575)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(-71.8824030337057, -13.2430981742233)
(-71.8824030337057, -607.92465558493)
(11.6453190586542, -591.24312267123)
(71.7502883947279, 9.80657068950669)
(71.7502883947279, 604.488128100213)
(-11.7774336976321, 587.806595186513)
(-71.8824030337057, -13.2430981742233)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.20520368775978698, -0.34364358640217296)
(0.4338720461513898, -0.34364358640217296)
(0.4338720461513898, -0.21954471142941387)
(0.20520368775978698, -0.21954471142941387)
(0.20520368775978698, -0.34364358640217296)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(-132.674868592199, 135.387305645642)
(-132.674868592199, -1381.9457077848)
(10.9578228362348, -1353.28182183437)
(132.199101204749, -140.869038149227)
(132.199101204749, 1376.46397528121)
(-11.4335902236844, 1347.80008933079)
(-132.674868592199, 135.387305645642)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.17083932911956973, -0.3260535571320574)
(0.41191757500844833, -0.3260535571320574)
(0.41191757500844833, -0.19141593033939383)
(0.17083932911956973, -0.19141593033939383)
(0.17083932911956973, -0.3260535571320574)
};
\addplot+[
solid, m2_color, mark=none, fill=m2_color, fill opacity=0.5
] coordinates {
(-270.869439370678, 884.244349008645)
(-270.869439370678, -3703.88931209218)
(-5.99546957373088, -3652.40634920687)
(269.845498732871, -893.996666140863)
(269.845498732871, 3694.13699495996)
(4.9715289359225, 3642.65403207465)
(-270.869439370678, 884.244349008645)
};
\addplot+[
solid, m1_color, mark=none, fill=m1_color
] coordinates {
(0.2082381056436471, -0.28339413344314346)
(0.32468031175604084, -0.28339413344314346)
(0.32468031175604084, -0.2033235983622052)
(0.2082381056436471, -0.2033235983622052)
(0.2082381056436471, -0.28339413344314346)
};
\coordinate (point) at (axis cs:0,0);
\coordinate (spy point) at (axis cs:400,0.8);
\spy on (point) in node (spy) at (spy point);
\end{axis}
\end{scope}
\end{tikzpicture}
\end{document}
答案1
在我看来(这值得我仔细研究一下)我们在这里达到了 TeX 和 TikZ 的极限。
由于轴环境240x207 pt
默认测量(约8.4 x 7.3 cm
)。您已选择放大倍数100
,并使用间谍(显示放大倍数的节点)4cm by 3 cm
,即约。114pt by 85 pt
乘以 100,因此此节点必须将原始图形上的面积扩大约一 pt(115/100 pt and 85/100 pt
)。
因此就出现了像素化。