7

I am trying to position nodes on a parabola curve. However, it seems tikz cannot calculate the midway positions. Neither of the following examples works:

\begin{tikzpicture}
    \draw (-1,0) parabola[parabola height=2cm] (3,0)
        node[sloped, above, pos=0.5] {0.5};
\end{tikzpicture}

\begin{tikzpicture}[to path={
    parabola[parabola height=2cm] (\tikztotarget) \tikztonodes}]
    \draw (0,0) to
        node[above, sloped] {0.5} (3,0);
\end{tikzpicture}

Any suggestions? Thanks!

Alan Munn
  • 218,180
ltxsun
  • 875
  • You can format your code examples by selecting the code and clicking on the 101 icon. I fixed this for you. – Alan Munn Jan 16 '11 at 04:31

1 Answers1

3

From the TikZ manual (section 16.8 “Placing Nodes on a Line or Curve Explicitly” in v2.10):

In the simplest case, the previous path operation was a “line-to” operation, that is, a -- coordinate operation [...]

The next case is the curve-to operation (the .. operation). [...]

Another interesting case are the horizontal/vertical line-to operations |- and -|. For them, the position (or time) 0.5 is exactly the corner point. [...]

For all other path construction operations, the position placement does not work, currently. This will hopefully change in the future (especially for the arc operation).

(emphasis mine)

So you either have to position the node by hand, or draw the parabola with an explicit Bézier curve.

Caramdir
  • 89,023
  • 26
  • 255
  • 291