Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 13 down vote accepted

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}

output of code

share|improve this answer
    
+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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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