# How to add arrows to an infinite line?

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?

-
The arrow was clipped (outside clipping box). Enlarge the clipping box, or shorten the domain to say 0.1:1 – Herr K. Nov 25 '13 at 3:26

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}


-
Removed braces; still no arrow. – crmdgn Nov 25 '13 at 3:20
@crmdgn Please see an addidional remark. – Przemysław Scherwentke Nov 25 '13 at 3:28
Found it. Fixed. – crmdgn Nov 25 '13 at 10:40

I'd use pgfplots (which is based on tikz) for this purpose

Here's some code to get you started- see the documentation and questions tagged with pgfplots on this site for more details.

% arara: pdflatex
\documentclass{standalone}

\usepackage{pgfplots}

% set the arrows as stealth fighters
\tikzset{>=stealth}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0,xmax=4,
ymin=0,ymax=3,
axis x line=middle,
axis y line=middle,
]
\end{axis}
\end{tikzpicture}
\end{document}

-

A recommended solution with PSTricks just for fun.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-node,pst-plot}

\begin{document}

\begin{pspicture}[showgrid=false](-2,-4)(3,4)
\psplot[algebraic,linecolor=blue,arrows=->]{-1.5}{1.5}{x^3}
\psaxes[linecolor=gray]{->}(0,0)(-2,-3.5)(2.5,3.5)[$x$,0][$y$,90]
\end{pspicture}
\end{document}


-
The \psaxes can be drawn first to make the graph on the top. – kiss my armpit Nov 25 '13 at 8:42