# Small Axis arrows in PGFplots

I would like to draw small arrows (through a macro probably), to show the coordinate directions like the plot below. It would be nice to have the option to turn on/off the grids as well.

The MWE for generating the plot:

\documentclass[12pt]{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}

\begin{axis}
[view = {120}{10}
,grid = both
]
\end{axis}

\end{tikzpicture}

\end{document}


-

A straight forward way is to set appropriate coordinates in the rel axis cs and then draw arrows outside the axis environement, such that the arrows don't get clipped by the axis.

The length of the hand drawn axis lines is controlled via \axislength. Replace \def\axislength{.2} with \def\axislength{.3} for instance to make them longer.

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\def\axislength{.2}
\begin{tikzpicture}
\begin{axis}[view = {120}{10},ticks=none,axis lines=none]
\coordinate (O) at (rel axis cs:1,0,0);
\coordinate (x) at (rel axis cs:1,\axislength,0);
\coordinate (y) at (rel axis cs:1-\axislength,0,0);
\coordinate (z) at (rel axis cs:1,0,\axislength);
\draw[->] (O) -- (x) node[above] {$x$};
\draw[->] (O) -- (y) node[above] {$y$};
\draw[->] (O) -- (z) node[right] {$z$};

Thanks @HenriMenke! Can we make the axis lines and labels disappear? Further, can we make the arrow length independent to the coordinate xmin,xmax, etc? – M.Reza Jul 11 '14 at 11:23
@M.Reza try ticks=none for hiding the ticks. If you want to get rid of the box around the plot, try axis lines=none. – s__C Jul 11 '14 at 11:45