[Tex/LaTex] Change Color of extra ticks grid

colorpgfplotstikz-pgf

I got a nice an d tidy plot with the help of pgfplot using groupeplot. Now I want to insert some extra ticks with different color than the major grid…everything works pretty well except the color line of the grid…I know extra ticks are treated as major ticks and for those

 major grid style = {red}

would change the color. But I can't find something like

 extra grid style = {red}

in the manual. All I can actually find is

 extra tick line style={red}

which only changes the color of the label entry of the extra tick. Does anybody knows a tiny and beautiful workaround?

Thank in advance,
CN

Best Answer

All the options that apply to ticks and grids can be specified separately for extra ticks by putting the options in extra tick style={...}. So if you want the major grid lines for the extra ticks to be red, you would set extra tick style={major grid style=red}:

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    grid=both,
    extra x ticks={1,3},
    extra tick style={
        major grid style=red,
        tick align=outside,
        tick style=red
    }
]
\addplot [black, only marks] {rnd};
\end{axis}
\end{tikzpicture}
\end{document}