Matplotlib: How to increase colormap/linewidth quality in streamplot?

I had another look at this and it wasnt as painful as I thought it might be.

Add:

    subdiv = 15
    points = np.arange(len(t[0]))
    interp_points = np.linspace(0, len(t[0]), subdiv * len(t[0]))
    tgx = np.interp(interp_points, points, tgx)
    tgy = np.interp(interp_points, points, tgy)
    tx = np.interp(interp_points, points, tx)
    ty = np.interp(interp_points, points, ty)

after ty is initialised in the trajectories loop (line 164 in my version). Just substitute whatever number of subdivisions you want for subdiv = 15. All the segments in the streamplot will be subdivided into as many equally sized segments as you choose. The colors and linewidths for each will still be properly obtained from interpolating the data.

Its not as neat as changing the integration step but it does plot exactly the same trajectories.

subdiv = 15


If you don't mind changing the streamplot code (matplotlib/streamplot.py), you could simply decrease the size of the integration steps. Inside _integrate_rk12() the maximum step size is defined as:

maxds = min(1. / dmap.mask.nx, 1. / dmap.mask.ny, 0.1)

If you decrease that, lets say:

maxds = 0.1 * min(1. / dmap.mask.nx, 1. / dmap.mask.ny, 0.1)

I get this result (left = new, right = original):

enter image description here

Of course, this makes the code about 10x slower, and I haven't thoroughly tested it, but it seems to work (as a quick hack) for this example.

About the density (mentioned in the comments): I personally don't see the problem of that. It's not like we are trying to visualize the actual path line of (e.g.) a particle; the density is already some arbitrary (controllable) choice, and yes it is influenced by choices in the integration, but I don't thing that it changes the (not quite sure how to call this) required visualization we're after.

The results (density) do seem to converge a bit for decreasing step sizes, this shows the results for decreasing the integration step with a factor {1,5,10,20}:

enter image description here