How do I set the color of the tick marks (major and minor) in pgfplots? It seems like a very basic question, but I cannot find it in the instructions. I would like to have black tick marks instead of the standard gray.
2 Answers
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[every x tick/.style={red}, minor x tick num=1]
\addplot {x^2};
\end{axis}
\end{tikzpicture}
\end{document}
Like this. You will finde all those styles for any element which can be adressed in the pgfplots manual. Those style btw will expand to every tick (x,y, and z) when you strip the x
. Result (detail):
Upon request: global options:
\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{every tick/.style={red,}, minor x tick num=1,}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot {x^2};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}
\addplot {x^3};
\end{axis}
\end{tikzpicture}
\end{document}
Every option which is set in \pgfplotsset
will be present in any axis
environment. See manual page 54 for details. Within this environment it's also possible to define own styles.
-
+1 could you demonstrate how to use
pgfplotsset
in the preamble to apply it globally (just in case the OP wants this)– cmhughesOct 15, 2012 at 16:24
\begin{axis}[
x tick style={color=black}
]
Include the above line, x tick style={color=black}
, in the argument list for \begin{axis}
.