# ListStreamPlot can't present closed curve with StreamStyle -> "Line"

I try this code to plot streamline

data = Table[{{x, y}, {-y, x}}, {x, -2, 2, 1/200}, {y, -2, 2, 1/200}];
ListStreamPlot[data, StreamStyle -> "Line", StreamPoints -> 4]


Question: In the picture, the lines are not closed in the red circles.

So, how to get closed curves use parameters of ListStreamPlot? Thank you!

• Might be hard to get to be done automatically, given that numerics usually won't give exactly closed curves, esp. with discrete data. -- I mean, with the discrete data, one has to assume how the vector field is to be estimated/interpolated. How do you know the resulting vector field has closed curves? Any perturbation of {-y, x} tends to destroy the closed curves. May 31, 2017 at 12:24
• @MichaelE2, I know that the data I want to plot has closed streamline from its physical meaning, so I want to get closed curves within MMA. In my question, I just present an example. How to get closed curves with some additional process? Thank you! May 31, 2017 at 13:16
• A hack: ListStreamPlot[data, StreamStyle -> "Line", StreamPoints -> 4] /. Line[{a_, b__}] :> Line[{a, b, a}] but it doesn't look good for the reason Michael gives. May 31, 2017 at 13:31
• Can you estimate a potential function or some invariant for the field? You could use it to draw level curves, which would approximate the closed orbits. May 31, 2017 at 16:17
• @MichaelE2, I cannot get potential function. I only have velocity vectors. Jun 2, 2017 at 2:59

Here's what I had in mind for estimating a potential function:

grad = MapAt[{-#[], #[]} &, data, {All, All, 2}];
pot = Accumulate@grad[[All, All, 2, 1]] + Accumulate /@ grad[[All, All, 2, 2]];

ListContourPlot[pot, DataRange -> {{-2., 2.}, {-2., 2.}}] The potential function could be multiplied by Δx Δy, but there's no real need to do it for the plot.

ListStreamPlot[data, StreamStyle -> "Line", StreamPoints -> 4] /.
Line -> (BSplineCurve[#, SplineClosed -> True] &) 