4

I want to add some arrows and words on a magnifying pic. Add A, B, and C on the magnifying pic. Could anybody help me fix this problem? Thanksenter image description here

    \begin{figure}
    \begin{tikzpicture}[scale=1,spy using outlines={circle, magnification=4,size=2.5cm, connect spies}]
    \coordinate (center) at (0,0);
    \coordinate (A) at (2,1.5);
    \coordinate (B) at (6,1.5);
    \coordinate (C) at (2,1);
    \coordinate (D) at (6,1);
    \coordinate (E) at (2,0);
    \coordinate (F) at (6,0);
    \coordinate (G) at (2,-1);
    \coordinate (H) at (6,-1);
    \coordinate (I) at (2,-1.5);
    \coordinate (J) at (6,-1.5);
    %Upper 
    \foreach \x / \y / \z in {3.9/1.5/K, 4.1/1.5/L, 3.9/1/M, 4.1/1/N,3.8/1.5/O, 3.8/1.3/P, 3.9/1.3/Q,  4.1/1.1/R, 4.2/1.1/S, 4.2/1.5/T}
    {\coordinate (\z) at (\x, \y);}
    \filldraw  (K)--(M)--(N)--(L)--(K);
    \draw (O)--(P)--(Q);
    \draw (R)--(S)--(T);
    %Lower 
    \foreach \x / \y / \z in {3.9/-1.5/K, 4.1/-1.5/L, 3.9/-1/M, 4.1/-1/N, 3.8/-1.5/O, 3.8/-1.3/P, 3.9/-1.3/Q,  4.1/-1.1/R, 4.2/-1.1/S, 4.2/-1.5/T}
    {\coordinate (\z) at (\x, \y);}
    \filldraw  (K)--(M)--(N)--(L)--(K);
    \draw (O)--(P)--(Q);
    \draw (R)--(S)--(T);
    %The left figure
    \draw [->] (-0.3,0.7) arc [start angle=150, end angle=30, radius=10pt];
    \draw (center) circle [radius=1.5cm];
    \draw (center) circle [radius=1cm];
    \foreach \x / \y in         {0/30,10/40,20/50,30/60,40/70,50/80,60/90,70/100,80/110,90/120,100/130,110/140,120/150,130/160,140/170,150/180,160/190,170/200,180/210,190/220,200/230,210/240,220/250,230/260,240/270,250/280,260/290,270/300,280/310,290/320,300/330,310/340,320/350,330/360,340/10,350/20}
    {\draw (\x:1) -- (\y:1.5);}
    %The right figure
    \draw (A)--(B);
    \draw (C)--(D);
    \draw (G)--(H);
    \draw (I)--(J);
    \draw (C) cos (1.86,0.5) sin (E);
    \filldraw [pattern=north east lines] (E) cos (2.14,-0.5) sin(G) cos (1.86,-0.5) sin (E);
    %\draw (E) cos (1.86,-0.5) sin (G);
    \draw (F) cos (6.14,-0.5) sin(H);
    \filldraw [pattern=north east lines](D) cos (6.14,0.5) sin (F) cos (5.86,0.5) sin (D);
    \draw [style=dashed] (-2,0)--(6.5,0) (0,2)--(0,-2);
    %located zoomed figure
    \spy [red] on (4,1.25) in node [spy] at (8,0);
    \end{tikzpicture}
    \end{figure}

2 Answers 2

3

Here is one way to do it. To make sure the arrows stay on top of the spied area I've used the backgrounds library. Made arrow B green to demonstrate it is indeed on top.

enter image description here

\documentclass[tikz,margin=0.5cm]{standalone}
\usetikzlibrary{patterns,spy,backgrounds}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

\begin{document}

    \begin{tikzpicture}[scale=1,spy using outlines={circle, magnification=4,size=2.5cm, connect spies}]
    \coordinate (center) at (0,0);
    \coordinate (A) at (2,1.5);
    \coordinate (B) at (6,1.5);
    \coordinate (C) at (2,1);
    \coordinate (D) at (6,1);
    \coordinate (E) at (2,0);
    \coordinate (F) at (6,0);
    \coordinate (G) at (2,-1);
    \coordinate (H) at (6,-1);
    \coordinate (I) at (2,-1.5);
    \coordinate (J) at (6,-1.5);
    %Upper 
    \foreach \x / \y / \z in {3.9/1.5/K, 4.1/1.5/L, 3.9/1/M, 4.1/1/N,3.8/1.5/O, 3.8/1.3/P, 3.9/1.3/Q,  4.1/1.1/R, 4.2/1.1/S, 4.2/1.5/T}
    {\coordinate (\z) at (\x, \y);}
    \filldraw  (K)--(M)--(N)--(L)--(K);
    \draw (O)--(P)--(Q);
    \draw (R)--(S)--(T);
    %Lower 
    \foreach \x / \y / \z in {3.9/-1.5/K, 4.1/-1.5/L, 3.9/-1/M, 4.1/-1/N, 3.8/-1.5/O, 3.8/-1.3/P, 3.9/-1.3/Q,  4.1/-1.1/R, 4.2/-1.1/S, 4.2/-1.5/T}
    {\coordinate (\z) at (\x, \y);}
    \filldraw  (K)--(M)--(N)--(L)--(K);
    \draw (O)--(P)--(Q);
    \draw (R)--(S)--(T);
    %The left figure
    \draw [->] (-0.3,0.7) arc [start angle=150, end angle=30, radius=10pt];
    \draw (center) circle [radius=1.5cm];
    \draw (center) circle [radius=1cm];
    \foreach \x / \y in         {0/30,10/40,20/50,30/60,40/70,50/80,60/90,70/100,80/110,90/120,100/130,110/140,120/150,130/160,140/170,150/180,160/190,170/200,180/210,190/220,200/230,210/240,220/250,230/260,240/270,250/280,260/290,270/300,280/310,290/320,300/330,310/340,320/350,330/360,340/10,350/20}
    {\draw (\x:1) -- (\y:1.5);}
    %The right figure
    \draw (A)--(B);
    \draw (C)--(D);
    \draw (G)--(H);
    \draw (I)--(J);
    \draw (C) cos (1.86,0.5) sin (E);
    \filldraw [pattern=north east lines] (E) cos (2.14,-0.5) sin(G) cos (1.86,-0.5) sin (E);
    %\draw (E) cos (1.86,-0.5) sin (G);
    \draw (F) cos (6.14,-0.5) sin(H);
    \filldraw [pattern=north east lines](D) cos (6.14,0.5) sin (F) cos (5.86,0.5) sin (D);
    \draw [style=dashed] (-2,0)--(6.5,0) (0,2)--(0,-2);
    %located zoomed figure
    \coordinate (zoomLoc) at (8,0);
    \spy [red] on (4,1.25) in node at (zoomLoc);

    \begin{pgfonlayer}{foreground}
    \draw [thick,<-] ([xshift=0.6cm,yshift=-0.3cm]zoomLoc)--++(-60:0.8cm)--++(0:0.7cm) node [right] {C};
    \draw [thick,<-] ([xshift=-0.6cm,yshift=0.5cm]zoomLoc)--++(70:1.2cm)--++(0:1.8cm) node [right] {A};
    \draw [green,thick,<-] ([xshift=0.3cm]zoomLoc)--++(70:1.2cm)--++(0:0.9cm) node [text=black,right] {B};
    \end{pgfonlayer}{foreground}

    \end{tikzpicture}
\end{document}
1
  • Thanks for your help. This is my first time I know pgflayer. I am learning pgflayer from the pgfmannual. Thanks again.
    – Yuchi
    Commented Aug 12, 2018 at 6:48
4

Here is an answer that is based on this older answer and conceptionally very similar to Milo's nice answer. The slight advantage is that this answer comes with a local coordinate system for the zoomed part, which may make it more straightforward to place the annotations. In particular, if you ever decide to move the zoomed in stuff around and/or change the zoom factor, the annotations will adjust. Milos approach is also fine with moving the zoomed stuff around. I also use outlined arrows for the sake of a better visibility.

\documentclass[tikz,margin=0.5cm]{standalone}
\usetikzlibrary{patterns,spy,backgrounds,calc,arrows.meta}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

\begin{document}
\tikzset{every spy on node/.append style={alias=zoom}}
    \begin{tikzpicture}[remember picture,scale=1,spy using outlines={circle, magnification=4,size=2.5cm, connect spies}]
    \coordinate (center) at (0,0);
    \coordinate (A) at (2,1.5);
    \coordinate (B) at (6,1.5);
    \coordinate (C) at (2,1);
    \coordinate (D) at (6,1);
    \coordinate (E) at (2,0);
    \coordinate (F) at (6,0);
    \coordinate (G) at (2,-1);
    \coordinate (H) at (6,-1);
    \coordinate (I) at (2,-1.5);
    \coordinate (J) at (6,-1.5);
    %Upper 
    \foreach \x / \y / \z in {3.9/1.5/K, 4.1/1.5/L, 3.9/1/M, 4.1/1/N,3.8/1.5/O, 3.8/1.3/P, 3.9/1.3/Q,  4.1/1.1/R, 4.2/1.1/S, 4.2/1.5/T}
    {\coordinate (\z) at (\x, \y);}
    \filldraw  (K)--(M)--(N)--(L)--(K);
    \draw (O)--(P)--(Q);
    \draw (R)--(S)--(T);
    %Lower 
    \foreach \x / \y / \z in {3.9/-1.5/K, 4.1/-1.5/L, 3.9/-1/M, 4.1/-1/N, 3.8/-1.5/O, 3.8/-1.3/P, 3.9/-1.3/Q,  4.1/-1.1/R, 4.2/-1.1/S, 4.2/-1.5/T}
    {\coordinate (\z) at (\x, \y);}
    \filldraw  (K)--(M)--(N)--(L)--(K);
    \draw (O)--(P)--(Q);
    \draw (R)--(S)--(T);
    %The left figure
    \draw [->] (-0.3,0.7) arc [start angle=150, end angle=30, radius=10pt];
    \draw (center) circle [radius=1.5cm];
    \draw (center) circle [radius=1cm];
    \foreach \x / \y in         {0/30,10/40,20/50,30/60,40/70,50/80,60/90,70/100,80/110,90/120,100/130,110/140,120/150,130/160,140/170,150/180,160/190,170/200,180/210,190/220,200/230,210/240,220/250,230/260,240/270,250/280,260/290,270/300,280/310,290/320,300/330,310/340,320/350,330/360,340/10,350/20}
    {\draw (\x:1) -- (\y:1.5);}
    %The right figure
    \draw (A)--(B);
    \draw (C)--(D);
    \draw (G)--(H);
    \draw (I)--(J);
    \draw (C) cos (1.86,0.5) sin (E);
    \filldraw [pattern=north east lines] (E) cos (2.14,-0.5) sin(G) cos (1.86,-0.5) sin (E);
    %\draw (E) cos (1.86,-0.5) sin (G);
    \draw (F) cos (6.14,-0.5) sin(H);
    \filldraw [pattern=north east lines](D) cos (6.14,0.5) sin (F) cos (5.86,0.5) sin (D);
    \draw [style=dashed] (-2,0)--(6.5,0) (0,2)--(0,-2);
    %located zoomed figure
    \coordinate (zoomLoc) at (8,0);
    \spy [red,on background layer,
    spy connection path={\draw (tikzspyonnode) -- (tikzspyinnode);
    \begin{pgfonlayer}{foreground} % https://tex.stackexchange.com/a/426272/121799
    \begin{scope}[shift={(tikzspyinnode.south west)},x={($(tikzspyinnode.south east)-(tikzspyinnode.south west)$)},
    y={($(tikzspyinnode.north west)-(tikzspyinnode.south west)$)}]
     \draw[{Latex[open]}-,black,double=white] (0.15,0.75) -- ++ (0.5,0.5) -- ++ (0.5,0) 
     node[right,minimum size=0pt]{A};
     \draw[{Latex[open,fill=white]}-,black,double=white] (0.5,0.5) -- 
     ++ (0.35,0.35) -- ++ (0.35,0)  node[right,minimum size=0pt]{B};
     \draw[{Latex[open,fill=white]}-,black,double=white] (0.8,0.4) -- 
     ++ (0.25,-0.25) -- ++ (0.15,0)  node[right,minimum size=0pt]{C};
    \end{scope}
    \end{pgfonlayer}}] on (4,1.25) in node at (zoomLoc);
    \end{tikzpicture}
\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .