答案1
这里有一个方法可以实现tikz
。
下面的代码显示了你的 4 种类型,最后是你的草图。使用下面的代码,可以很容易地以模块化的方式逐步创建其他类似复杂程度的图表:
\usetikzlibrary{decorations.markings}
% ~~~ PROCEDURE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% 0. use or include the `\tikzset` statement below
% 1. put coordinates
% 2. put nodes with labels, using the text styles tl, tr
% 3. draw one path
% 3a. use normal `--` first
% 3b. replace as needed, e.g. by `to [bend left]` etc.
% 4. turn `\draw` into `\draw[postaction={decorate}]`
% 5. copy decoration style and adjust the `mark=at position` statements as needed
\tikzset{
mat/.style={circle,draw,inner sep=2pt},% matrix element
tl/.style={xshift=-2.5mm},% shift text to left
tr/.style={xshift= 2.5mm},% shift text to right
lp/.style={min distance=12mm},% loop style
}
请注意,单条路径有时会跳过画线。
是的,你仍然可以改进香蕉;-)
\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
% ~~~ PROCEDURE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% 0. use or include the `\tikzset` statement below
% 1. put coordinates
% 2. put nodes with labels, using the text styles tl, tr
% 3. draw one path
% 3a. use normal `--` first
% 3b. replace as needed, e.g. by `to [bend left]` etc.
% 4. turn `\draw` into `\draw[postaction={decorate}]`
% 5. copy decoration style and adjust the `mark=at position` statements as needed
\tikzset{
mat/.style={circle,draw,inner sep=2pt},% matrix element
tl/.style={xshift=-2.5mm},% shift text to left
tr/.style={xshift= 2.5mm},% shift text to right
lp/.style={min distance=12mm},% loop style
}
\begin{document}
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{tikzpicture}% type 1
[decoration={
markings,
mark=at position 0.1 with {\arrow{stealth}},
mark=at position 0.25 with {\arrow{stealth}},
mark=at position 0.4 with {\arrow{stealth}},
mark=at position 0.6 with {\arrow{stealth}},
mark=at position 0.9 with {\arrow{stealth}},
}]
\coordinate (K) at ( 0,0);
\coordinate (P1) at ( 20:4);
\coordinate (P2) at (-10:4);
\coordinate (M) at ( 10:2);
\node[tl] at (K) {$K$};
\node[tr,yshift=1mm] at (P1) {$\pi$};
\node[tr] at (P2) {$\pi$};
\node[mat] at (M) {};
\draw[postaction={decorate}]
(K) to [bend left] (M)
to [bend left] (P1) to [bend left] (M)
to [bend right] (P2) to [bend left] (K);
\end{tikzpicture}
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{tikzpicture}% type 2
[decoration={
markings,
mark=at position 0.1 with {\arrow{stealth}},
mark=at position 0.33 with {\arrow{stealth}},
mark=at position 0.5 with {\arrow{stealth}},
mark=at position 0.7 with {\arrow{stealth}},
mark=at position 0.9 with {\arrow{stealth}},
}]
\coordinate (K) at (0,0);
\coordinate (P1) at ( 10:2);
\coordinate (P2) at (-10:2);
\coordinate (M) at (0:1);
\node[tl] at (K) {$K$};
\node[tr] at (P1) {$\pi$};
\node[tr] at (P2) {$\pi$};
\node[mat] at (M) {};
\draw[postaction={decorate}] (K) to [bend left] (M) to [bend right] (P2) to [bend left] (P1) to [bend right] (M) to [bend left] (K);
\end{tikzpicture}
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{tikzpicture}% type 3
[decoration={
markings,
mark=at position 0.1 with {\arrow{stealth}},
mark=at position 0.24 with {\arrow{stealth}},
mark=at position 0.4 with {\arrow{stealth}},
mark=at position 0.55 with {\arrow{stealth}},
mark=at position 0.8 with {\arrow{stealth}},
}]
\coordinate (K) at ( 0,0);
\coordinate (P1) at ( 20:4);
\coordinate (P2) at (-10:4);
\coordinate (M) at ( 10:2);
\node[tl] at (K) {$K$};
\node[tr] at (P1) {$\pi$};
\node[tr] at (P2) {$\pi$};
\node[mat] at (M) {};
% loop WAS missing
\draw[postaction={decorate}]
(K) to [bend left] (M)
to [out=-20,in=-150,lp] (M)
to [bend left] (P1) to [bend right] (P2) to [bend left] (K);
\end{tikzpicture}
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{tikzpicture}% type 4
[decoration={
markings,
mark=at position 0.1 with {\arrow{stealth}},
mark=at position 0.36 with {\arrow{stealth}},
mark=at position 0.53 with {\arrow{stealth}},
mark=at position 0.73 with {\arrow{stealth}},
mark=at position 0.89 with {\arrow{stealth}},
}]
\coordinate (K) at (0,0);
\coordinate (P1) at ( 10:4);
\coordinate (P2) at (-10:4);
\coordinate (M) at ( 0:2);
\node[tl] at (K) {$K$};
\node[tr] at (P1) {$\pi$};
\node[tr] at (P2) {$\pi$};
\node[mat] at (M) {};
\draw[postaction={decorate}]
(K) to [bend left] (M)
to [out=-20,in=20,lp] (M)
to [bend left] (K)
(P1) to [bend right] (P2) to [out=180,in=180] (P1);
\end{tikzpicture}
% ~~~ sketch ~~~~~~~~~~~~~~~~~~~
\begin{tikzpicture}
[decoration={
markings,
mark=at position 0.2 with {\arrow{stealth}},
mark=at position 0.45 with {\arrow{stealth}},
mark=at position 0.77 with {\arrow{stealth}},
mark=at position 0.9 with {\arrow{stealth}},
}]
\coordinate (K) at (0,0);
\coordinate (P0) at (3,0);
\coordinate (Pp) at (3,2);
\coordinate (H) at (30:2.5);
\node[tl] at (K) {$K^+$};
\node[tr] at (P0) {$\pi^0$};
\node[tr,yshift=2mm] at (Pp) {$\pi^+$};
\draw[postaction={decorate}]
(K) to [bend left] (P0)
to [bend left] (K)
(H) to [bend left] (Pp) to [bend left] (H);
\draw[dashed] (1.5,.5) to [bend left] (H);
\draw[red,line width=1.5pt] (.9,1.0) to [bend left] (2.5,.6);
\end{tikzpicture}
\end{document}