2
$\begingroup$

I am trying to make a StreamPlot with few streamlines, but I would like these streamlines to be smooth, and they are not. Here is the code

B[g_] := -1 - g^2 + 1/10 g^3
zz = NSolve[B[g] == 0, g][[2, 1, 2]];

StreamPlot[-{Re[B[a + I b]], Im[B[a + I b]]}, {a, -2, 2}, {b, -2.2, 2.2}, Axes -> False, 
StreamPoints -> {{1, 0}, {Re[zz], Im[zz] - .4}, {Re[zz], -Im[zz] + .4}, {1, .32}, {1, -.32}},
StreamScale -> None, Frame -> None, StreamStyle -> {Red, "Arrow"}, AspectRatio -> .8, PerformanceGoal -> "Quality", ImageSize -> Large]

and the result is enter image description here

As you can see this has the problem that the streamlines are not always smooth (especially when they are turning a lot). How can I make it so that they are smoother?

$\endgroup$

1 Answer 1

3
$\begingroup$
postprocess = # /. Line[x_] :> Line[BSplineFunction[x] /@ Range[0, 1, 1/1000]] &;

sp = StreamPlot[-{Re[B[a + I b]], Im[B[a + I b]]}, {a, -2,  2}, {b, -2.2, 2.2}, 
  Axes -> False, 
  StreamPoints -> {{1, 0}, {Re[zz], Im[zz] - .4}, {Re[zz], -Im[zz] + .4}, 
     {1, .32}, {1, -.32}}, 
  StreamScale -> None, Frame -> None, StreamStyle -> {Red, "Arrow"}, 
  AspectRatio -> .8, PerformanceGoal -> "Quality", 
  ImageSize -> Large];

postprocess @ sp

enter image description here

i = 1; 
Row[Show[#, PlotRange -> {{-.5, .5}, All}, ImageSize -> 500, 
    PlotLabel -> ((Style[#, 20] & /@ {"sp", "postprocess @ sp"})[[i++]])] & /@ 
 {sp, postprocess@sp}, Spacer[10]]

enter image description here

$\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.