Appearantly I don't understand how scope works.

The following compiles fine:

\addplot3[samples y=0] plot (x, x, -x*x);

but the following gives the error Package pgfkeys Error: I do not know the key '/tikz/samples y':

\begin{scope}[samples=20,samples y=0,domain=0:12]
\addplot3 plot (x, x, -x*x);

How can I use the samples y option in the scope?

Edit: This is a MWE that does not work, because samples y is in the scope:

\addplot3[domain=0:1, y domain=0:1, surf] plot (x, y, {x*y});
\begin{scope}[domain=0:1,samples y=0]
\addplot3 plot (x, x, 0);
  • 3
    samples y is a pgfplots option. But a scope evaluates its option in TikZ key family.
    – percusse
    Commented Apr 23, 2017 at 7:52
  • While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. This is especially important for tikz as there are numerous libraries. Commented Apr 23, 2017 at 8:07
  • @percusse, Do you know of some way to put samples y into a scope to prevent me from repeating this option for a large amount of similar addplot3's?
    – Carucel
    Commented Apr 23, 2017 at 8:16
  • 2
    Use the full key: /pgfplots/samples y=0.
    – esdd
    Commented Apr 23, 2017 at 9:45

1 Answer 1


Pgfplots options, such as samples y, cannot go directly in a scope like Tikz options can, like

\begin{scope}[samples y=0]

but have to be prefixed by /pgfplots/ like

\begin{scope}[/pgfplots/samples y=0]

[Credit goes to user esdd who solved answered me in the comment]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .