3

I am trying to draw a smooth curve in tikz that has an arrow tip both at the "beginning" and at the "ending". It works fine when I add an arrow tip at the ending only (black curve below). However, when also specifying an arrow tip at the beginning the shape of the curve changes considerably and looks bumpy (red curve below):

enter image description here

How can I add the arrow tip at both sides and still have the shape of the black curve?

The code which I have used so far is:

\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}
3

You need to load the bending library:

\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}

Then it works.

enter image description here

  • it is pretty unusual to use scope for define styles ... and also use pgfplots when the tikz is sufficient :-) – Zarko Aug 23 '16 at 7:58
  • I agree, but why are you telling this to me? I just reused the code provided by the original poster : ) – Nico Boni Aug 23 '16 at 8:00
  • Right, I will replace $scope$ ... $pgfplots$ is required for the rest of my document, that's how it made it inot the MWE. – LaTeX User Aug 23 '16 at 8:07
  • Thank you very much for pointing me to $bending$. Unfortunately, it shortens the red path too much with the $-Latex$ arrow tip. Is there a workaround for this? – LaTeX User Aug 23 '16 at 8:08
  • well, I didn't addressed comment specifically to you :-). More serious: I observe, that dashed line is draw different, it start/ends far from start/end coordinates. – Zarko Aug 23 '16 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.