状态图中的循环节点

状态图中的循环节点

我觉得这应该很简单,但我找不到怎么做。我试图在状态图中绘制一个围绕节点角落的箭头。我有以下方法,但如您所见,它会切开角落,而且理想情况下箭头会从更靠近角落的地方循环。

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\pagestyle{empty}

\begin{tikzpicture}[%node distance = 15mm and 300mm,
    node/.style={
        draw,
        rectangle,
        text width=25mm,
        text centered,
        minimum height=20mm
    },  
    arrow/.style={
        very thick,
        ->
    }]

\node[node] (state) {State};

\draw [arrow] (state.south)  to [out=270, in=0]  (state.east);

\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

您有几种可能性:您可以使用.. controls ..语法,或者out=<value>,in=<value>,loop选项也许与适当的looseness,或(如)相结合杰克建议)你可以使用和arc来获得适当的圆弧:

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\pagestyle{empty}

\begin{tikzpicture}[%node distance = 15mm and 300mm,
    node/.style={
        draw,
        rectangle,
        text width=25mm,
        text centered,
        minimum height=20mm
    },  
    arrow/.style={
        very thick,
        ->
    }]

\node[node] (state) {State};

\draw[red] [arrow] (state.270) .. controls  (0.5,-3) and (3.5,-1) ..  (state.0);
\draw[blue] (state) edge [out=270,in=0,loop] (state);
\draw[green] (state) edge [out=270,in=0,loop,looseness=4] (state);
\draw [arrow] (state.south east) ++(-0.75cm,0pt) arc [start angle=-180, end angle=90, radius=0.75cm];

\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容