According to the docs, the meaning of the arguments passed to ParametricPlot3D is $x, y, z, u, v$. This is 5 arguments: the Cartesian coordinates and the two parameters. Similarly, for ParametricPlot it's $x, y, u, v$.

Let's look at how many arguments are actually passed to the ColorFunction:

Reap[ParametricPlot3D[{Cos[u] Cos[v], Sin[u] Cos[v], Sin[v]}, 
       {u, 0, 2 Pi}, {v, -Pi/2, Pi/2}, ColorFunction -> ((Sow[{##}]; Gray) &)]]

If you evaluate this, you'll notice that actually 6 arguments are passed to the colour function, but the last one is always zero. If we use the one-parameter form of ParametricPlot3D, then still six arguments will be passed, but now the last two are zero.

Reap[ParametricPlot3D[{Cos[u], Sin[u], 0}, {u, 0, 2 Pi}, 
  ColorFunction -> ((Sow[{##}]; Gray) &)]]

Similarly, the colour function of ParametricPlot receives 5 arguments instead of 4.

What is the meaning of the last argument passed to the ColorFunction of these functions? Does it have any use? Does ParametricPlot3D have a form where the last argument of the colour function will not be zero and has an application?

  • $\begingroup$ I just tested with RegionPlot3D and plain Plot: Both also add an extra 0. argument. $\endgroup$ – celtschk May 16 '12 at 12:20
  • 7
    $\begingroup$ "Reserved for future use"? $\endgroup$ – Sjoerd C. de Vries May 16 '12 at 12:52
  • $\begingroup$ @Sjoerd Well, they could always just add one more argument ... $\endgroup$ – Szabolcs May 21 '12 at 14:58
  • 1
    $\begingroup$ Interesting -- this explians why a color function defined per the ColorFunction docs with 5 arguments doesn't work!! mycolor[x_, y_, z_, u_, v_] := Red; ParametricPlot3D[{Cos[u] Cos[v], Sin[u] Cos[v], Sin[v]}, {u, 0, 2 Pi}, {v, -Pi/2, Pi/2}, ColorFunction -> (mycolor[##] &)] produces an 'uncolored' figure.. Apologies I cant see how to post a comment vs an 'answer' here.. $\endgroup$ – george2079 Aug 20 '12 at 22:07

This is a bit speculative but I note that SphericalPlot3D[] supplies its ColorFunction with 6 args, being x, y, z, theta, phi, and r. SphericalPlot3D can be shown to call ParametricPlot3D, so I'd surmise the extra argument is left there for compatibility.

  • $\begingroup$ Sounds plausible +1 $\endgroup$ – Dr. belisarius Aug 21 '12 at 19:45
  • 1
    $\begingroup$ How did you find this out? Did you use Trace? $\endgroup$ – rcollyer Aug 22 '12 at 2:13
  • 2
    $\begingroup$ Unprotect[ParametricPlot3D];ParametricPlot3D[arg___] := (Print["arg list is", {arg}]); SphericalPlot3D[1, {t, 0, 2 Pi}, {p, -Pi/2, Pi/2}, ColorFunction -> colorfunction ] $\endgroup$ – george2079 Aug 22 '12 at 14:43

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.