MathGroup Archive 2011

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

Search the Archive

Re: Contour ColorFunction in a ParametricPlot


I don't think there is such a Directive. As far as I know, Tooltip only 
works on objects directly; you can't specify it as a Directive
for a Graphics Primitive. It's a bit messy but one solution would be to 
do something like this

Module[{colours, plot, meshr = Range[-1, 1, 2/10]},
 colours = Hue /@ Rescale[meshr];

 plot =
  ParametricPlot3D[{Cos[\[Phi]] Sin[\[Theta]],
    Sin[\[Phi]] Sin[\[Theta]], Cos[\[Theta]]}, {\[Phi], 0,
    2 \[Pi]}, {\[Theta], 0, \[Pi]}, PlotPoints -> 100,
   MeshFunctions -> {Function[{x, y, z, \[Phi], \[Theta]},
      Sin[6  Rescale[\[Phi], {0, 2 Pi}]] Sin[
        6 Rescale[\[Theta], {0, Pi}]]]},
   Mesh -> {meshr}, MeshStyle -> None, MeshShading -> colours,
   Lighting -> "Neutral"];

 plot /. {a___, k_ /; MemberQ[colours, k], c___} :> {a, k,
    c /. {Polygon[d_] :>
       Tooltip[Polygon[d], Pick[meshr, colours, k][[1]]]}}]

This basically generates the plot as before but then replaces the 
occurrences of Polygon[...] in the plot with Tooltip[Polygon[...],label] where
label is the value of the contour which corresponds to the colour of the Polygon.

Heike


On 12 Jul 2011, at 12:00, Blandeau M.N. wrote:

> Thank you very much Bob and Heike.
>
> For this example Heike's solution with mesh seems more efficient, the plot
> is easier to manipulate and  the precision of the contour is better compared to the number of point in the directive "PlotPoints" (I guess this is because the mesh works with lines only whereas Bob's solution works with entire surfaces).
>
> I still have one simple question :
> What is the directive to see the value of the MeshFunction or ContourPlot when you pass the mouse above ? Will this directive still work if you use the Function "Show[{ParametricPlot[...],...}]" ?
>
> Thanks again
> Mathias
>
> -----Original Message-----
> From: Heike Gramberg [mailto:heike.gramberg at gmail.com]
> Sent: 09 July 2011 12:31
> To: mathgroup at smc.vnet.net
> Subject: Re: Contour ColorFunction in a ParametricPlot
>
>
> On 8 Jul 2011, at 09:51, Bob Hanlon wrote:
>
>>
>> contours = 6;
>> ParametricPlot3D[
>> {Cos[p] Sin[t], Sin[p] Sin[t], Cos[t]}, {p, 0, 2 Pi}, {t, 0, Pi},
>> PlotPoints -> 200, Mesh -> None, ColorFunction -> Function[{x, y, z,
>> p, t},
>>  Hue[Round[Sin[6 p] Sin[6 t], 1/contours]]], ColorFunctionScaling ->
>> True]
>>
>>
>> Bob Hanlon
>>
>
> Another way to create this effect would be to use MeshFunctions in combination with MeshShading:
>
> With[{meshn = 10},
> ParametricPlot3D[{Cos[\[Phi]] Sin[\[Theta]],
>   Sin[\[Phi]] Sin[\[Theta]], Cos[\[Theta]]}, {\[Phi], 0,
>   2 \[Pi]}, {\[Theta], 0, \[Pi]}, PlotPoints -> 100,
>  MeshFunctions -> {Function[{x, y, z, \[Phi], \[Theta]},
>     Sin[6  Rescale[\[Phi], {0, 2 Pi}]] Sin[
>       6 Rescale[\[Theta], {0, Pi}]]]},
>  Mesh -> meshn, MeshShading -> Table[Hue[i], {i, 0, 1, 1/meshn}],
>  MeshStyle -> None, Lighting -> "Neutral"]]
>
> Heike.
>
>
>> ---- "Blandeau M.N." <mnb1f10 at soton.ac.uk> wrote:
>>
>> =============
>> Hello,
>> I looked for this specific question in the archive and I did not find.
>>
>> I want to create a contour (ie. not smooth) ColorFunction over a parametricplot.
>>
>> For example:
>> ParametricPlot3D[ {Cos[ \[Phi]] Sin[\[Theta]],  Sin[\[Phi]]
>> Sin[\[Theta]], Cos[\[Theta]]}, {\[Phi], 0,
>> 2 \[Pi]}, {\[Theta], 0, \[Pi]}, PlotPoints -> 100, Mesh -> None,
>> ColorFunction ->  Function[{x, y, z, \[Phi], \[Theta]},
>>  Hue[Sin[6 \[Phi]] Sin[6 \[Theta]]]], ColorFunctionScaling -> True]
>>
>> Here the colorfunction is smooth, what directive should I add to obtain acontour of the colour and to manage the number of contours ?
>>
>> Thanks in advance.
>>
>> Mathias Blandeau
>>
>>
>> From: Blandeau M.N.
>> Sent: 06 July 2011 14:35
>> To: 'mathgroup at smc.vnet.net'
>> Subject: subscription to mathgroup mailing list
>>
>> Hi,
>> I would like to be added to the mathgroup mailing list, I am using Mathematica for my PhD and I have several questions to ask.
>> Thank you in advance
>>
>> Mathias Blandeau
>>
>>
>
>
>



  • Prev by Date: Biokmod 5 for Mathematica 8.0
  • Next by Date: Interpolation problems
  • Previous by thread: Re: Contour ColorFunction in a ParametricPlot
  • Next by thread: Re: Bug 1+4/10