15
$\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$
3
  • 1
    $\begingroup$ Look up mollweide on this site? $\endgroup$ Commented Nov 11, 2014 at 7:29
  • 1
    $\begingroup$ @chris Mollweide should be a mapping to 2D. A 3D is strongly prefer for the visualization. $\endgroup$ Commented Nov 11, 2014 at 7:38
  • 5
    $\begingroup$ closely related: Phase portrait on a cylinder $\endgroup$ Commented Nov 11, 2014 at 8:12

2 Answers 2

19
$\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$
15
$\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$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.