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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am asking if there is a command in the pgfplots package that changes the appearance of the grid in terms of kind of the lines. What I mean is how to change the kind of lines. I have read the documentation but I could not find anything on this issue.

share|improve this question
@Jake I wouldn't change the color but I would have a different kind of lines like loosely dotted or dotted style – Mazzy Jan 10 '13 at 16:43
yeah it worked!!! – Mazzy Jan 10 '13 at 18:17
up vote 30 down vote accepted

As with most of the settings in pgfplots, you can set these things globally in the preamble using \pgfplotsset

For example

  • minor ticks: \pgfplotsset{minor grid style={dashed,red}}
  • major ticks: \pgfplotsset{major grid style={dotted,green!50!black}}
  • both minor and major ticks: \pgfplotsset{grid style={dashed,gray}}

A complete MWE follows



% grid style
\pgfplotsset{grid style={dashed,gray}}
\pgfplotsset{minor grid style={dashed,red}}
\pgfplotsset{major grid style={dotted,green!50!black}}


                             minor xtick={-5,-3,...,5},
        \addplot {x^2};
share|improve this answer

Your Answer


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.