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.

5
  • 1
    Possibly related: tex.stackexchange.com/q/128579/82917
    – campa
    Commented Nov 2, 2023 at 8: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. Commented Nov 2, 2023 at 9: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
    Commented Nov 2, 2023 at 9: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. Commented Nov 2, 2023 at 13:09
  • I found the answer on the Tikz manual, thanks!
    – Andros
    Commented Nov 3, 2023 at 9:57

1 Answer 1

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!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .