I have this code to plot contours:

ContourPlot[(Cos[θ] Cos[ϕ])^(1/4), {θ, -π/2, π/2}, {ϕ, -π/2, π/2}, AxesLabel -> Automatic]

How would I map those contours on a unit sphere (if it is even possible) where θ and ϕ are the spherical angles for the sphere (θ is the inclination calculated from the xy plane and ϕ is azimuth calculated from the x-axis)?

In a post here, I saw a different problem and the suggestion was to use MeshFunctions so I tried:

ParametricPlot3D[{Sin[ϕ] Cos[θ],Cos[ϕ] Cos[θ],Sin[θ]},
{θ, -π/2, π/2}, {ϕ, -π/2, π/2}, 
 MeshFunctions -> {
ContourPlot[(Cos[θ] Cos[ϕ])^(1/4), {θ, -π/2, π/2}, {ϕ, -π/2, π/2}, 
    AxesLabel -> Automatic]

but it spits errors and I do not even know whether this approach is correct.


You could use SliceContourPlot3D:

expr = TransformedField["Spherical" -> "Cartesian",
 (Cos[θ - π/2] Cos[ϕ])^(1/4), {r, θ, ϕ} -> {x, y, z}];

SliceContourPlot3D[expr, "CenterSphere", {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]

enter image description here

The missing parts of the sphere are where your expression isn't real.

  • $\begingroup$ Note that the OP's phi is not the traditional spherical phi: phi = 0 is the xy plane for the OP. At least that's how I read it before. $\endgroup$ – Michael E2 Jan 16 '16 at 17:00
  • $\begingroup$ @MichaelE2, thanks, I hadn't spotted that. $\endgroup$ – Simon Woods Jan 16 '16 at 17:07

EDIT: Corrected slot numbers per input from Simon Wood.

Look at the documentation for MeshFunctions

ParametricPlot3D[{Sin[ϕ] Cos[θ], 
  Cos[ϕ] Cos[θ], 
  Sin[θ]}, {θ, -π/2, π/2}, {ϕ, -π/
   2, π/2}, MeshFunctions -> {(Cos[#4] Cos[#5])^(1/4) &},
 PlotPoints -> 50]

enter image description here

  • $\begingroup$ The parameters theta and phi are #4 and #5 in the mesh function. $\endgroup$ – Simon Woods Jan 16 '16 at 16:23

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.