我的问题如下。我想在 spy 的放大区域上绘制(放大的)轴。例如,以下示例(来自 pgfplots.pdf,第 121 页):
% Preamble: \pgfplotsset{width=7cm,compat=1.5.1}
% requires \usetikzlibrary{spy}
\begin{tikzpicture}[spy using outlines=
{circle, magnification=6, connect spies}]
\begin{axis}[no markers,grid=major,
every axis plot post/.append style={thick}]
\addplot coordinates
{(0, 0.0) (0, 0.9) (1, 0.9) (2, 1) (3, 0.9) (80, 0)};
\addplot +[line join=round] coordinates
{(0, 0.0) (0, 0.9) (2, 0.9) (3, 1) (4, 0.9) (80, 0)};
\addplot +[line join=bevel] coordinates
{(0, 0.0) (0, 0.9) (3, 0.9) (4, 1) (5, 0.9) (80, 0)};
\addplot +[miter limit=5] coordinates
{(0, 0.0) (0, 0.9) (4, 0.9) (5, 1) (6, 0.9) (80, 0)};
\coordinate (spypoint) at (axis cs:3,1);
\coordinate (magnifyglass) at (axis cs:60,0.7);
\end{axis}
\spy [blue, size=2.5cm] on (spypoint)
in node[fill=white] at (magnifyglass);
\end{tikzpicture}
我想在放大镜中绘制轴(带有新网格)以(近似地)查看(x,y)中的峰值。有点像 DataGraph 软件中的“放大镜”工具。这可能吗?
答案1
评论
使用Christian Feuersänger 链接的问题,我能够举一个例子。
代码
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.5.1}
\usetikzlibrary{spy}
\begin{document}
\begin{tikzpicture}[every pin/.style={fill=white}]
\begin{axis}[
no markers,
grid=major,
every axis plot post/.append style={thick}
]
\addplot coordinates {(0, 0.0) (0, 0.9) (1, 0.9) (2, 1) (3, 0.9) (80, 0)};
\addplot +[line join=round] coordinates {(0, 0.0) (0, 0.9) (2, 0.9) (3, 1) (4, 0.9) (80, 0)};
\addplot +[line join=bevel] coordinates {(0, 0.0) (0, 0.9) (3, 0.9) (4, 1) (5, 0.9) (80, 0)};
\addplot +[miter limit=5] coordinates {(0, 0.0) (0, 0.9) (4, 0.9) (5, 1) (6, 0.9) (80, 0)};
\coordinate (spypoint) at (axis cs:3,1);
\end{axis}
\node[pin={[pin distance=1.5cm]357:{%
\begin{tikzpicture}[baseline,trim axis left,trim axis right]
\begin{axis}[
no markers,
grid=major,
every axis plot post/.append style={thick},
tiny,
xmin=1,xmax=6,
ymin=0.95,ymax=1.02,
]
\addplot coordinates {(0, 0.0) (0, 0.9) (1, 0.9) (2, 1) (3, 0.9) (80, 0)};
\addplot +[line join=round] coordinates {(0, 0.0) (0, 0.9) (2, 0.9) (3, 1) (4, 0.9) (80, 0)};
\addplot +[line join=bevel] coordinates {(0, 0.0) (0, 0.9) (3, 0.9) (4, 1) (5, 0.9) (80, 0)};
\addplot +[miter limit=5] coordinates {(0, 0.0) (0, 0.9) (4, 0.9) (5, 1) (6, 0.9) (80, 0)};
\end{axis}
\end{tikzpicture}%
}},draw,circle,minimum size=0.5cm] at (spypoint) {};
\end{tikzpicture}
\end{document}