1

I have this curve made with TikZ:

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture} \draw [cyan,line width=1mm] plot [smooth, tension=2] coordinates { (0,0) (5,3) (9,-1) (11,4)} ; \end{tikzpicture}

\end{document}

enter image description here

I would like to place several nodes on this plot. I know this is somehow possible within the axis environment but I have no idea how to do it here.

Qrrbrbirlbel
  • 119,821
Andros
  • 167
  • 1
    Possibly related: https://tex.stackexchange.com/q/128579/82917 – campa Nov 02 '23 at 08:52
  • 2
    The non-accepted answer of @campa's link is relevant as well as it explains the background of how “nodes along a path” works internally. It requires a “timer”. The plot operation doesn't provide one. You either have to use PGFPlots, the decoration.markings library or the spath3 library which basically does the same as decoration.markings. – Qrrbrbirlbel Nov 02 '23 at 09:19
  • 1
    Here's the a section of tikz manual related to placing nodes on a curve. Since you are using plot, you may need another approach. See this question. – Celdor Nov 02 '23 at 09:50
  • 1
    Another word: the normal TikZ timer doesn't place nodes linear to the length of a curve linear to the time (hence the name). That's the t variable in the function for a Bézier curve. The decoration.markings library does work differently as even unitless values are considered fractions of the total length of the decorated path. If you want something timer like for the individual curves that the PGF plot handlers generate, we will have to dig into the internals. spath3 could help here maybe. – Qrrbrbirlbel Nov 02 '23 at 13:09
  • I found the answer on the Tikz manual, thanks! – Andros Nov 03 '23 at 09:57

1 Answers1

2

So I went to the TikZ manual as suggested by @Celdor and I did the following

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture} \draw [cyan,line width=1mm] (0,0) .. controls (3,5) and (6,-1) .. (7,2) node (a1) [pos=0.1,circle,draw,inner sep=0pt,minimum size=5pt,fill]{} node (a2) [pos=0.3,circle,draw,inner sep=0pt,minimum size=5pt,fill]{} node (a3) [pos=0.8,circle,draw,inner sep=0pt,minimum size=5pt,fill]{} ; \end{tikzpicture}

\end{document}

which produces the following: enter image description here

Thanks!

Andros
  • 167