tikz:平滑的曲线和箭头

tikz:平滑的曲线和箭头

我正在尝试在 tikz 中绘制一条平滑的曲线,该曲线在“开始”和“结束”处都有箭头。当我仅在结尾处添加箭头时,它工作正常(下面的黑色曲线)。但是,当在开头也指定箭头时,曲线的形状会发生很大变化并且看起来凹凸不平(下面的红色曲线):

在此处输入图片描述

我怎样才能在两侧添加箭头并仍保留黑色曲线的形状?

我迄今为止使用的代码是:

\documentclass{standalone}

\usepackage{pgfplots}
\usetikzlibrary{arrows,arrows.meta}

\begin{document}

\begin{tikzpicture}

\begin{scope}[
    every node/.style = {
        draw            = green,
        fill            = green,
        inner sep       = 0pt,
        circle,
        minimum size    = 2pt,
        font            = \footnotesize,
}]

\node   (A1)    at (30:3.00cm){};
\node   (A2)    at (35:9.00cm){};
\node   (A3)    at (125:4.00cm){};

\end{scope}

\draw[thick,black] plot [smooth,tension=1] coordinates {(A1) (A2) (A3)};
\draw[-Latex,thick,black] plot [smooth,tension=1] coordinates {(A1) (A2) (A3)};
\draw[Latex-Latex,thick,red,dashed] plot [smooth,tension=1] coordinates {(A1) (A2) (A3)};

\end{tikzpicture}

\end{document}

答案1

您需要加载bending库:

\documentclass{standalone}

\usepackage{pgfplots}
\usetikzlibrary{arrows,arrows.meta,bending} %new code

\begin{document}

\begin{tikzpicture}

\begin{scope}[
    every node/.style = {
        draw            = green,
        fill            = green,
        inner sep       = 0pt,
        circle,
        minimum size    = 2pt,
        font            = \footnotesize,
}]

\node   (A1)    at (30:3.00cm){};
\node   (A2)    at (35:9.00cm){};
\node   (A3)    at (125:4.00cm){};

\end{scope}

\draw[thick,black] plot [smooth,tension=1] coordinates {(A1) (A2) (A3)};
\draw[-Latex,thick,black] plot [smooth,tension=1] coordinates {(A1) (A2) (A3)};
\draw[Latex-Latex,thick,red,dashed] plot [smooth,tension=1] coordinates {(A1) (A2) (A3)};

\end{tikzpicture}

\end{document}

然后它就起作用了。

在此处输入图片描述

相关内容