I am trying to add arrows pointing on the axis lines for the following graph:

\documentclass{article}
\usepackage{xcolor}
\usepackage{pgfplots}
\usepackage{amsmath}

\begin{document}

\begin{figure}[ht]

\centering

\begin{tikzpicture}[scale=1.75,line width=1pt]
\begin{axis}[
color= gray,
xmin=-4.9, 
xmax=4.9, 
ymin=-1.9, 
ymax=2.9, 
axis equal image, 
axis lines=middle, 
font=\scriptsize,
xtick distance=1,
ytick distance=1,
xticklabels={}, 
yticklabels={},
legend pos=outer north east,
]

\addplot[red, smooth, domain=-4.9:4.9] {(8)/(4 + x^2)}; 
\addlegendentry{$f(x)$}

\addplot[blue, smooth, domain=-4.9:4.9]{(-16*x)/((4+x^2)^2)};
\addlegendentry{$f'(x)$}

\addplot[green, smooth, domain=-4.9:4.9]{-(((16)*((4 + x^2)^2))-((4 + x^2)* 
(64*(x^2))))/((4+x^2)^4)};
\addlegendentry{$f''(x)$}


\end{axis}
\end{tikzpicture}

\caption{Plotting the curve when $r=1$.}
\label{fig:1}

\end{figure}

\end{document}

Here is the output of the code:

axis

See how only the top and the right end of the axis lines have arrow pointers, and the bottom and the left do not? Is there a way so I could get some on all four ends?

Thanks!

up vote 5 down vote accepted

Add

every inner x axis line/.append style={stealth-stealth},
every inner y axis line/.append style={stealth-stealth},

at the end of your axis options, just after the legend pos=outer north east, and just before the ]

See section 4.9.9 of the current reference manual.

If you are happy with them both being the same, you could just set a single key (as pointed out in the comments):

inner axis line style={stealth-stealth}
  • 2
    Slightly shorter would be inner axis line style={stealth-stealth}. – Torbjørn T. Oct 21 at 20:57
  • Great response, a quick easy solution to my problem! Much appreciated! – Aiden Kenny Oct 22 at 1:49

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.