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?


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:


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

  • 1
    Thanks. I actually tried this, but seems I made a typo... sample instead of samples... – Foo Bar Oct 10 '12 at 18:05
  • 1
    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
  • 1
    @zeroth agreed; +1 for both :) – cmhughes Oct 10 '12 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.