I was looking at the tikz/pgf manual (section 22.5), and they have the code

    \draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
    \draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
    \draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
    \draw[color=red] plot (\x,\x) node[right] {$f(x) =x$};
    % \x r means to convert '\x' from degrees to _r_adians:
    \draw[color=blue] plot (\x,{sin(\x r)}) node[right] {$f(x) = \sin x$};
    \draw[color=orange] plot (\x,{0.05*exp(\x)}) node[right] {$f(x) = \frac{1}{20} \mathrm e^x$};

But if I try to move the node of say $f(x) = \sin x$ to 80% of the way along the curve, I would think that

        \draw[color=blue] plot (\x,{sin(\x r)}) node[pos=.8] {$f(x) = \sin x$};

should work but it doesn't. I assume this is an issue with plot no knowing things, but is there any solution that doesn't involve me just declaring a node manually in space?

  • 3
    Actually, it shouldn't work, if I read the manual correctly. The pos parameter isn't implemented for the plot operation. Related: tex.stackexchange.com/questions/172842 tex.stackexchange.com/questions/437732 – Torbjørn T. Jul 25 '18 at 2:18
  • 1
    You have all data. At pos=0.8 the coordinate is (3.2,{sin(3.2 r)}). – user121799 Jul 25 '18 at 5:44
  • @torbjørn-t Thank you for those references. The workaround in the 2nd link using decoration is very nice. – D.J. Jul 25 '18 at 13:32
  • @marmot Yes, though I know the point, I was just looking to avoid declaring the node manually. – D.J. Jul 25 '18 at 13:32
  • 1
    @marmot I did refer to tex.stackexchange.com/a/437754 above ... – Torbjørn T. Jul 25 '18 at 20:47

Your Answer

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

Browse other questions tagged or ask your own question.