如何更改连接间谍和被监视区域的线的线宽

如何更改连接间谍和被监视区域的线的线宽

我正在试验这个spy库。它工作得很好,除了在使用关键字时会影响间谍连接的线宽connect spies,或者要监视的区域轮廓的宽度。我尝试在任何地方插入像ultra thick或这样的关键字line width=3mm,但没有效果。手册只说“使得监视节点和被监视节点通过一条细线连接起来。”关键字connect spies,但没有粗线选项。我还查看了 tex.sx 上有关该spy库的所有问题,但没有找到任何内容。

那么是否有可能将一些选项传递给这些行(可能dashed其他东西也可能有用),如果是,如何传递?

这是我目前的代码:

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{spy,calc}

\begin{document}

\begin{tikzpicture}[spy using outlines={circle, size=2cm, connect spies}]
    %\includegraphics[scale=1]{test.png}
    \node[above right, inner sep=0] at (0,0) {\includegraphics{test.png}};
    \draw[very thin, yellow] (0,0) grid (15.25,10);
    \spy[magnification=3,red,draw,line width=1mm] on (2,2) in node[ultra thick] at (3,-2);
    \spy[magnification=5,green] on (7.1,4.1) in node[line width=4mm] at (8,-2);
    \spy[magnification=10,black] on (11.8,2.8) in node[dashed,line width=1mm] at (13,-2);
\end{tikzpicture}

\end{document}

在此处输入图片描述


最后,如果你想用原始图片进行实验的话,可以看一下:

在此处输入图片描述

答案1

spy connection path用于绘制spy inspy on节点之间的连接。它在两个节点创建后执行。通过使用样式connect spiesspy connection path键设置为\draw[thin] (tikzspyonnode) -- (tikzspyinnode);。这在手册第 465 页中有说明。TikZ因此,为了影响连接spy inspy on节点的路径,我们需要指定代码。这可以在命令spy connection path中简单地完成。options\spy

\documentclass{standalone}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{spy,calc}
\begin{document}
  \begin{tikzpicture}[spy using outlines={circle, size=2cm}]
    \node[above right, inner sep=0] at (0,0) {\includegraphics{test.png}};
    \draw[very thin, yellow] (0,0) grid (15.25,10);
    \spy[magnification=3,spy connection path={\draw[thick] (tikzspyonnode) -- (tikzspyinnode);}] on (2,2) in node at (3,-2);
    \spy[magnification=5,spy connection path={\draw[thick, green] (tikzspyonnode) -- (tikzspyinnode);}] on (7.1,4.1) in node[green] at (8,-2);
    \spy[magnification=10,spy connection path={\draw[thick, dashed] (tikzspyonnode) -- (tikzspyinnode);}] on (11.8,2.8) in node[dashed] at (13,-2);
  \end{tikzpicture}
\end{document}

有特殊关系的间谍

更新:为了影响外观on nodes,我们需要定义自己的外观spy scope并使用键来改变行为。以下示例说明了这一点:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{spy}
\begin{document}
  \tikzset{
    my spy on/.style={#1},
    my spy/.style={
      spy scope={
        every spy on node/.style={
          draw,
          circle, 
          size=2cm,
          my spy on,
        },
        every spy in node/.style={
          draw,
          black,
          size=2cm,
          thick,
          circle,
        },
      #1
      }
    }
  }
  \begin{tikzpicture}[my spy]
    \node[above right, inner sep=0] at (0,0) {\includegraphics{test.png}};
    \draw[very thin, yellow] (0,0) grid (15.25,10);
    \spy[magnification=3,spy connection path={\draw[thick, black] (tikzspyonnode) -- (tikzspyinnode);}, my spy on={red, very thick}] on (2,2) in node at (3,-2);
    \spy[magnification=5,spy connection path={\draw[thick, green] (tikzspyonnode) -- (tikzspyinnode);}] on (7.1,4.1) in node[green] at (8,-2);
    \spy[magnification=10,spy connection path={\draw[thick, dashed,black] (tikzspyonnode) -- (tikzspyinnode);}, my spy on={green, thick}] on (11.8,2.8) in node[dashed] at (13,-2);
  \end{tikzpicture}
\end{document}

现在,样式#1中的my spy允许向 中添加其他选项spy scopemy spy on样式用于设置 的选项on node。结果如下所示:

有特殊关系且位于节点上的间谍

相关内容