MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Q about ParametricPlot3D

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110021] Re: Q about ParametricPlot3D
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sat, 29 May 2010 04:44:58 -0400 (EDT)

On 5/28/10 at 7:21 AM, stevebg at ROADRUNNER.COM (S. B. Gray) wrote:

>I would appreciate advice on these questions:

>1. Why do I need Table in this expression:

>ParametricPlot3D[Table[{(Cos[ang] xb + Sin[ang] yb)*radb + cenb,
>(Cos[ang] xa + Sin[ang] ya)*rada + cena}^], {ang, 0, 2\[Pi]},
>PlotStyle -> {Blue, Thickness[.01]}]

>2. In the no-Table form that I expected to work,
>ParametricPlot3D[{(Cos[ang] xb + Sin[ang] yb)*radb + cenb, (Cos[ang]
>xa + Sin[ang] ya)*rada + cena},
>{ang, 0, 2\[Pi]}, PlotStyle -> {Blue, Thickness[.01]}]

>the Blue option works only for the first line and the Thickness
>option works only on the second line. (?) The first version (1.)
>works correctly but I don't know the syntax for giving each circle a
>different color. In actual use I will have a dozen or more circles
>and it is desirable to make every one have a different color.

>3. In the first version I have put a ^ after "cena}" as a substitute
>for a similar symbol put there by Mathematica that's aligned with
>the bottom of the line. I think it's a warning but I don't know what
>it means. The plot works correctly even with it.

The code you posted is incomplete making it impossible for me to
evaluate it and determine exactly what the difference are that
you are seeing. But having said that, my guess is the issue is
the way Mathematica plotting works.

Basically, Mathematica substitutes numeric values for the
dependent variable then evaluates the expression to be plotted
rather than first evaluating the expression then substituting a
numeric value for the dependent variable. This is key to
understanding how to get plots in various colors.

For example doing

Plot[Table[n Sin[x], {n, 3}], {x, 0, 2 \[Pi]}]

results in a plot with three curves all the same color. Since
Mathematica assigns values to x before evaluating the Table
construct, the three numeric values returned by the Table
construct are seen as a single multi-valued function.
Consequently, only the first item of any PlotStyle directive
list is applied to all three curves. Contrast this with

a = Table[n Sin[x], {n, 3}];
Plot[a, {x, 0, 2 \[Pi]}]

Now the result is the same three curves with three different
colors. Here a has Head List which Mathematica sees as a list of
three single valued functions. Now, a list of PlotStyle
directives work as expected with the first directive in the list
being applied to the first function and so on.

The same result can be obtained by using Evaluate as follows:

Plot[Evaluate@Table[n Sin[x], {n, 3}], {x, 0, 2 \[Pi]}]

Here, the Table construct is forced to evaluate before any
numerica assignment is made by Plot. The result is something
with Head LIst which Mathematica sees as three single valued functions.

My guess is inserting Evaluate in front of Table as I do here in
the preceding example will result in the plot you are looking for.



  • Prev by Date: Re: Eric Weisstein's MathWorld packages
  • Next by Date: Re: Graphics questions
  • Previous by thread: Re: Q about ParametricPlot3D
  • Next by thread: Graphics questions