Consider the example
plotOptions = {PlotPoints -> 10, MaxRecursion -> 2}
Plot3D[x y , {x, 0, 10}, {y, 0, 10}, plotOptions]
Why does this causes the error:
Plot3D::nonopt: Options expected (instead of plotOptions) beyond position 3 in
Plot3D[x y,{x,0,10},{y,0,10},plotOptions]. An option must be a rule or a list of rules. >>
?
I would say that plotOptions
is as list of rules...
If I use
Plot3D[x y , {x, 0, 10}, {y, 0, 10}, {PlotPoints -> 10, MaxRecursion -> 2}]
it works:
What is then the correct way of passing a list of options to a plot? One situation on when this happens is when I want to create several plots with the same options.
Plot3D[x y, {x, 0, 10}, {y, 0, 10},Evaluate@plotOptions]
its because of theHoldAll
attribute of Plot functions! $\endgroup$ – PlatoManiac Feb 11 '13 at 10:59HoldAll
attribute. I'll let @PlatoManiac post the answer. $\endgroup$ – Ajasja Feb 11 '13 at 11:03Hold
, etc. $\endgroup$ – murray Feb 11 '13 at 17:12