[Tex/LaTex] How to add arrows to an infinite line

arrowstikz-pgf

I'm graphing part of a parabola, like so:

\documentclass{article}
\usepackage{tikz}

\begin{document}

    \begin{tikzpicture}
        \clip (-0.1,-0.1) rectangle (4,3);
        \draw[->] (0,0) -- (4,0);
        \draw[->] (0,0) -- (0,3);% draw axis lines
        \draw[domain=0.1:2,red,->,thick,samples=400] plot ({\x},{\x^3} );% draw plot
    \end{tikzpicture}

\end{document}

As you see, I'm trying to put an arrowhead onto the upward end of the parabola line, but it's not happening. I hypothesize that it's because the line is infinite, so there's no end to put an arrowhead on. Is that right? And in any case, is there a way to put an arrowhead on to that line?

Best Answer

In this case the TeX grouping braces are the source of error:

\documentclass{article}
\usepackage{tikz}

\begin{document}

    \begin{tikzpicture}
        \clip (-0.1,-0.1) rectangle (4,3);
        \draw[->] (0,0) -- (4,0);
        \draw[->] (0,0) -- (0,3);% draw axis lines
  %      \draw[domain=0.1:2,red,->,thick,samples=400] plot ({\x},{\x^3} );% draw plot
\draw[domain=0.1:2,red,->,thick,samples=400] plot (\x,\x^3 );% draw plot
    \end{tikzpicture}

\end{document}

If you choose:

\documentclass{article}
\usepackage{tikz}

\begin{document}

    \begin{tikzpicture}
      \clip (-0.1,-0.1) rectangle (4,3);
        \draw[->] (0,0) -- (4,0);
        \draw[->] (0,0) -- (0,3);% draw axis lines
  %      \draw[domain=0.1:2,red,->,thick,samples=400] plot ({\x},{\x^3} );% draw plot
\draw[domain=0.1:1.44,red,->,thick,samples=400]  plot (\x,\x^3 );% draw plot
    \end{tikzpicture}

\end{document}

(max about 1.44 instead of 2), you can see the arrowhead.

enter image description here

Related Question