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:

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

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

Any suggestions? Thanks!

  • 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 4:31

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.

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.