# PGFPlots: Change the color of axis lines

I want to change the color of the axis lines only without changing the color of the axis labels, tick labels etc.

MWE:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
%
\begin{document}
%
\pgfplotsset{
every axis/.append style={%
red
}
}
%
\begin{tikzpicture}
\begin{axis}[%
xlabel={X},
ylabel={Y}
]%
\end{axis}
\end{tikzpicture}
%
\end{document}


I am not aware of a pgfkey for axis lines only along the lines of /pgfplots/tick style.

-

You can set the axis labels and tick labels independently, but as Jake notes in the comments, you can also just set the axis line style. I've modified your example to show all three

\documentclass[png,border=4pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

%
\pgfplotsset{
axis line style={red},
every axis label/.append style ={blue},
every tick label/.append style={green}
}
%

\begin{document}
\begin{tikzpicture}
\begin{axis}[%
xlabel={X},
ylabel={Y}
]%
\end{axis}
\end{tikzpicture}
%
\end{document}


-
+1 how about moving pgfplotsset to the preamble? :) –  cmhughes Dec 7 '12 at 22:31
You could also use the key axis line style=red to only turn the axis lines red. That way, you don't have to look up all the styles required to turn things back to black. –  Jake Dec 7 '12 at 23:12
@Jake Thanks. I should have left this to the experts. I'll updated my answer. –  Alan Munn Dec 8 '12 at 0:01