\( \newcommand{\N}{\mathbb{N}} \newcommand{\R}{\mathbb{R}} \newcommand{\C}{\mathbb{C}} \newcommand{\Q}{\mathbb{Q}} \newcommand{\Z}{\mathbb{Z}} \newcommand{\P}{\mathcal P} \newcommand{\B}{\mathcal B} \newcommand{\F}{\mathbb{F}} \newcommand{\E}{\mathcal E} \newcommand{\brac}[1]{\left(#1\right)} \newcommand{\abs}[1]{\left|#1\right|} \newcommand{\matrixx}[1]{\begin{bmatrix}#1\end {bmatrix}} \newcommand{\vmatrixx}[1]{\begin{vmatrix} #1\end{vmatrix}} \newcommand{\lims}{\mathop{\overline{\lim}}} \newcommand{\limi}{\mathop{\underline{\lim}}} \newcommand{\limn}{\lim_{n\to\infty}} \newcommand{\limsn}{\lims_{n\to\infty}} \newcommand{\limin}{\limi_{n\to\infty}} \newcommand{\nul}{\mathop{\mathrm{Nul}}} \newcommand{\col}{\mathop{\mathrm{Col}}} \newcommand{\rank}{\mathop{\mathrm{Rank}}} \newcommand{\dis}{\displaystyle} \newcommand{\spann}{\mathop{\mathrm{span}}} \newcommand{\range}{\mathop{\mathrm{range}}} \newcommand{\inner}[1]{\langle #1 \rangle} \newcommand{\innerr}[1]{\left\langle #1 \right \rangle} \newcommand{\ol}[1]{\overline{#1}} \newcommand{\toto}{\rightrightarrows} \newcommand{\upto}{\nearrow} \newcommand{\downto}{\searrow} \newcommand{\qed}{\quad \blacksquare} \newcommand{\tr}{\mathop{\mathrm{tr}}} \newcommand{\bm}{\boldsymbol} \newcommand{\cupp}{\bigcup} \newcommand{\capp}{\bigcap} \newcommand{\sqcupp}{\bigsqcup} \newcommand{\re}{\mathop{\mathrm{Re}}} \newcommand{\im}{\mathop{\mathrm{Im}}} \newcommand{\comma}{\text{,}} \newcommand{\foot}{\text{。}} \)

Sunday, June 15, 2014

[Tikz] Draw contours with midway arrow

The code is as follows: In the preamble, paste (with the package "tikz" loaded of course!):
 \usetikzlibrary{decorations.pathreplacing,decorations.markings}  
 \tikzset{  
  % style to apply some styles to each segment of a path  
  on each segment/.style={  
   decorate,  
   decoration={  
    show path construction,  
    moveto code={},  
    lineto code={  
     \path [#1]  
     (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);  
    },  
    curveto code={  
     \path [#1] (\tikzinputsegmentfirst)  
     .. controls  
     (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)  
     ..  
     (\tikzinputsegmentlast);  
    },  
    closepath code={  
     \path [#1]  
     (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);  
    },  
   },  
  },  
  % style to add an arrow in the middle of a path  
  mid arrow/.style={postaction={decorate,decoration={  
     markings,  
     mark=at position .5 with {\arrow[#1]{stealth}}  
    }}},  
 }  

As an exmaple, see:

 \begin{tikzpicture}[scale=2]  
 \clip (0.6,3.75) rectangle (3.85,0.85);  
 \draw[thick] (0,0) ellipse (3 and 3);  
 \draw[postaction={on each segment={mid arrow}}] (60:2) arc (60:30:2) -- (30:2.8) arc(30:60:2.8)--cycle;  
 \draw[postaction={on each segment={mid arrow}}] (30:4.2)arc (30:60:4.2) --(60:3.2)arc (60:30:3.2)--cycle;  
 \node at (1.745,1.795) {$L_1(r)$};  
 \node at (0.9,2.15) {$L_2(r)$};  
 \node at (1.225,1.2) {$L_3(r)$};  
 \node at (2.275,1) {$L_4(r)$};  
 \node at (2.5,2.425) {$T_1(r)$};  
 \node at (3.45,1.65) {$T_2(r)$};  
 \node at (3.225,3.125) {$T_3(r)$};  
 \node at (1.575,3.325) {$T_4(r)$};  
 \end{tikzpicture}  

No comments:

Post a Comment