MathGroup Archive 2012

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

Search the Archive

Re: Plotting colorfunctions over multiple parametric curves

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125240] Re: Plotting colorfunctions over multiple parametric curves
  • From: "djmpark" <djmpark at comcast.net>
  • Date: Thu, 1 Mar 2012 05:36:10 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <2205388.63106.1330519615741.JavaMail.root@m06>

Andrew,

The proper procedure is to set ColorFunctionScaling to False, and then use
the Rescale function to map the potential range onto the interval 0 to 1.

n = 3;
XYR = ({{-2.1, 0, 1.0}, {0, 0, 0.5}, {2.1, 0, 1.0}});
x[i_] := XYR[[i, 1]];
y[i_] := XYR[[i, 2]];
r[i_] := XYR[[i, 3]];

potential[theta_, i_] := theta + 1.0;
circle[i_, theta_] := {x[i] + r[i]*Cos[theta], y[i] + r[i]*Sin[theta]};

Show[
 Table[
  ParametricPlot[circle[i, theta], {theta, 0, 2 Pi},
   PlotStyle -> Thick,
   Axes -> False,
   ImageSize -> 200,
   ColorFunction ->
    Function[{x, y, theta}, 
     ColorData["TemperatureMap"][
      Rescale[potential[theta, i], {1, 2 \[Pi] + 1}]]],
   ColorFunctionScaling -> False], {i, 1, n}],
 PlotRange -> All] 

The plotting could be done a little more simply using the Presentations
application.

<<Presentations`

Draw2D[
 {Thick,
  ParametricDraw[circle[#, theta], {theta, 0, 2 \[Pi]},
     ColorFunction ->
      Function[{x, y, theta}, 
       ColorData["TemperatureMap"][
        Rescale[potential[theta, #], {1, 2 \[Pi] + 1}]]],
     ColorFunctionScaling -> False
     ] & /@ {1, 2, 3}},
 ImageSize -> 200]


David Park
djmpark at comcast.net 
http://home.comcast.net/~djmpark/index.html 





From: Andrew Green [mailto:kiwibooga at googlemail.com] 


Hi Bob

Thanks for the reply. I am a step further thank you, but the results are
strange.  It is as if the colorfunction is clipping values below 0 and above
1 - it is not scaling even if ColorFunctionScaling->true is added. Consider
potential[theta_,i_] = theta+1.0, I would have expected you should still get
a full rainbow of colors (0 to 2pi mapped to 0 to 1), instead all are red.

n = 3;
XYR = ( {
    {-2.1, 0, 1.0},
    {0, 0, 0.5},
    {2.1, 0, 1.0}
   } );
x[i_] := XYR[[i, 1]];
y[i_] := XYR[[i, 2]];
r[i_] := XYR[[i, 3]];

potential[theta_, i_] := theta + 1.0;
circle[i_, theta_] := {x[i] + r[i]*Cos[theta], y[i] + r[i]*Sin[theta]};

Show[Table[
  ParametricPlot[circle[i, theta], {theta, 0, 2 Pi}, 
   PlotStyle -> Thick, Axes -> False, ImageSize -> 200, 
   ColorFunction -> 
    Function[{x, y, theta}, 
     ColorData["TemperatureMap"][potential[theta, i]]], 
   ColorFunctionScaling -> True], {i, 1, n}], PlotRange -> All]

Any ideas why?

Thanks - Andrew




  • Prev by Date: Re: Why no OpenCL output on iMac OS X Lion?
  • Next by Date: Re: How add a menu item with a menu key using an init.m
  • Previous by thread: Re: Plotting colorfunctions over multiple parametric curves
  • Next by thread: Re: nested sums