11
$\begingroup$

Suppose I have some vector field equations $(f(\theta,\phi), g(\theta,\phi))$. The StreamPlot can be created easily in 2D, but I would like to visualize the stream line plot in a 3D spherical surface $(\theta,\phi)$, so how can it be done? As an example:

StreamPlot[{Cot[θ]Cos[ϕ],- Sin[ϕ]}, {ϕ,-π,π},{θ,0,π}, StreamColorFunction->Hue]

enter image description here

Ideally, the front of spherical surface should be partially transparent so that the flow line at the rear end can be visualized at the same time.

$\endgroup$
  • $\begingroup$ Look up mollweide on this site? $\endgroup$ – chris Nov 11 '14 at 7:29
  • $\begingroup$ @chris Mollweide should be a mapping to 2D. A 3D is strongly prefer for the visualization. $\endgroup$ – unsym Nov 11 '14 at 7:38
  • 4
    $\begingroup$ closely related: Phase portrait on a cylinder $\endgroup$ – Kuba Nov 11 '14 at 8:12
16
$\begingroup$

An alternative way to post-process the StreamPlot output into a Graphics3D object using @user18792's trick:

sp = StreamPlot[{Cot[θ] Cos[ϕ], -Sin[ϕ]}, {ϕ, -π, π}, {θ, 0, π}, StreamColorFunction -> Hue, 
   ImageSize -> 400];

sp3d = Graphics3D[sp[[1]] /. Arrow[z_] :> 
       Arrow[z /. {x_Real, y_Real} :> {Cos[x] Sin[y], Sin[y] Sin[x],  Cos[y]}], ImageSize -> 400];
Row[{sp, sp3d}, Spacer[5]]

enter image description here

To add a semi-transparent Sphere:

Graphics3D[{sp[[1]] /. Arrow[z_] :> 
             Arrow[z /. {x_Real, y_Real} :> {Cos[x] Sin[y], Sin[y] Sin[x], Cos[y]}], 
            Opacity[.5], Sphere[]}, ImageSize -> 400]

enter image description here

$\endgroup$
14
$\begingroup$
gr = Normal@StreamPlot[{Cot[θ] Cos[ϕ], -Sin[ϕ]}, {ϕ, -π, π}, {θ, 0, π}, 
  StreamColorFunction -> Hue];

Graphics3D[Cases[gr, _Arrow, Infinity] /. 
  {x_Real, y_Real} :> {Cos[x] Sin[y], Sin[y] Sin[x], Cos[y]}]

Mathematica graphics

$\endgroup$

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.