5
$\begingroup$

This question follows from the example below

Mapping StreamPlot onto spherical surfaces

When I'm trying to remove the arrows I cannot get the 3d graphics:

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

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

The result is below. Any idea how to get the 3d graphics without the arrows?

enter image description here

$\endgroup$

2 Answers 2

2
$\begingroup$

You can also post-process the graphics objects sp and sp3d from the accepted answer in the the linked q/a (1) to change Arrows to Lines or (2) to change the Arrowheads directive to Arrowheads[0]:

sp = StreamPlot[{Cot[θ] Cos[ϕ], -Sin[ϕ]}, {ϕ, - π, π}, {θ, 0, π}, 
  StreamColorFunction -> Hue, ImageSize -> 200];
sp3d = Graphics3D[sp[[1]] /.  Arrow[z_] :>  
     Arrow[z /. {x_Real, y_Real} :> {Cos[x] Sin[y], Sin[y] Sin[x], Cos[y]}], 
  ImageSize -> 200];

Row[{sp, sp3d} /. Arrow -> Line, Spacer[5]]

enter image description here

Row[{sp, sp3d} /. Arrowheads[_] :> Arrowheads[0], Spacer[5]]

same picture

$\endgroup$
4
$\begingroup$

The sp output includes a GraphicsComplex, so the arguments of the primitives are indices into the GraphicsComplex and not coordinates. Also, your StreamPlot uses Line primitives instead of Arrow primitives. So, a corrected version would be:

Graphics3D[
    ReplaceAll[
        Normal[sp][[1]],
        Line[z_]:>Line[z/.{x_Real,y_Real}:>{Cos[x] Sin[y],Sin[y] Sin[x],Cos[y]}]
    ]
]

enter image description here

Note that Normal modifies the colors, so an alternative is to transform the GraphicsComplex:

Graphics3D[
    ReplaceAll[
        sp[[1]],
        {x_Real,y_Real}:>{Cos[x] Sin[y],Sin[y] Sin[x],Cos[y]}
    ],
    ImageSize->400
]

enter image description here

The latter method is identical to @Jason's now deleted answer.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.