# pgfplots: how to set default number of samples?

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?

-
possible duplicate of Global variables for all tikz drawings in a document – zeroth Oct 10 '12 at 20:26

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

-
Thanks. I actually tried this, but seems I made a typo... sample instead of samples... – Foo Bar Oct 10 '12 at 18:05
and of course, it can be overwritten locally, e.g `samples=15` – cmhughes Oct 10 '12 at 18:26
@cmhughes maybe this is actually a dublicate of my added link? – zeroth Oct 10 '12 at 19:04
@zeroth agreed; +1 for both :) – cmhughes Oct 10 '12 at 19:50