[Tex/LaTex] pgfplots: how to set default number of samples

pgfplotsplot

For most of the functions I have to plot with \addplot of pgfplots, I have to set [samples=200] to make them look smooth enough. I was wondering if there is some option to set the default sample number to a specific value so that I don't have to type it over and over again. I could not find one.

Is there such an option?

Best Answer

Many options in the pgf, TikZ and pgfplots family have all their options defaulted in some way. This also means that you can set them wherever you want and obtain a default.

In this case you can set the option in the preample or where-ever needed as this:

\pgfplotsset{samples=200}

This will make all subsequent plots using the samples key use 200 samples.

Inspired by cmhughes, for another question I have answered describing the scopes of keys and how they can be used in a short generalized manner, see Global variables for TikZ drawings