我有一个带弯曲箭头的 tikz 图表,不知何故 tikz 在箭头上绘制了箭头注释(在我的情况下只是数字)。当箭头弯曲时,这种情况更常发生。似乎 tikz 不知道注释相对于箭头的位置。我有下面的独立代码。我想要的是注释位于弯曲之上,并且我希望与箭头之间有一个我可以控制的最小距离(以像素为单位?)。Tikz 中有类似的东西吗?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.5cm,
thick,main node/.style={circle,fill=blue!10,draw,font=\sffamily\Large\bfseries}]
% nodes
\node[main node] (A) {A};
\node[main node] (B) [below left of=A] {B};
\node[main node] (C) [below right of=A] {C};
\node[main node] (D) [below right of=B] {D};
\node[main node] (E) [right of=C] {E};
\node[main node] (F) [above of=E] {F};
% lines
\path[every node/.style={font=\sffamily\small}]
(A) edge [bend right] node [right] {0.0} (B)
(B) edge [loop left] node {0.0} (B)
edge [bend right] node [right] {0.0} (D)
edge [bend right] node[right] {0.0} (C)
(C) edge [bend right] node [left] {0.0} (A)
edge [bend right] node [left] {0.0} (B)
edge [bend left] node [left] {0.0} (D)
edge [right] node [right] {0.0} (E)
(D) edge [loop below] node {0.0} (D);
\end{tikzpicture}
\end{document}
答案1
我只是将一些“右”和“左”替换为“上”和“下”
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.5cm,
thick,main node/.style={circle,fill=blue!10,draw,font=\sffamily\Large\bfseries}]
% nodes
\node[main node] (A) {A};
\node[main node] (B) [below left of=A] {B};
\node[main node] (C) [below right of=A] {C};
\node[main node] (D) [below right of=B] {D};
\node[main node] (E) [right of=C] {E};
\node[main node] (F) [above of=E] {F};
% lines
\path[every node/.style={font=\sffamily\small}]
(A) edge [bend right] node [right] {0.0} (B)
(B) edge [loop left] node {0.0} (B)
edge [bend right] node [right] {0.0} (D)
edge [bend right] node[below] {0.0} (C)
(C) edge [bend right] node [right] {0.0} (A)
edge [bend right] node [above] {0.0} (B)
edge [bend left] node [left] {0.0} (D)
edge [right] node [above] {0.0} (E)
(D) edge [loop below] node {0.0} (D);
\end{tikzpicture}
\end{document}