Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e7ca3a3

Browse files
committed
Merge pull request #789 from tonysyu/fix-streamplot
Fix streamplot for non-square grids.
2 parents ec1cd25 + dbc4324 commit e7ca3a3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/matplotlib/streamplot.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import numpy as np
66
import matplotlib
77
import matplotlib.patches as patches
8-
import matplotlib.cbook as cbook
98

109

1110
__all__ = ['streamplot']
@@ -332,9 +331,11 @@ def backward_time(xi, yi):
332331
return -dxi, -dyi
333332

334333
def integrate(x0, y0):
335-
"""Return x, y coordinates of trajectory based on starting point.
334+
"""Return x, y grid-coordinates of trajectory based on starting point.
335+
336+
Integrate both forward and backward in time from starting point in
337+
grid coordinates.
336338
337-
Integrate both forward and backward in time from starting point.
338339
Integration is terminated when a trajectory reaches a domain boundary
339340
or when it crosses into an already occupied cell in the StreamMask. The
340341
resulting trajectory is None if it is shorter than `minlength`.
@@ -446,10 +447,10 @@ def _integrate_rk12(x0, y0, dmap, f):
446447

447448
def _euler_step(xf_traj, yf_traj, dmap, f):
448449
"""Simple Euler integration step."""
449-
nx, ny = dmap.grid.shape
450+
ny, nx = dmap.grid.shape
450451
xi = xf_traj[-1]
451452
yi = yf_traj[-1]
452-
cx, cy = f(xi, yi) # ds.cx is in data coordinates, ds in axis coord.
453+
cx, cy = f(xi, yi)
453454
if cx > 0:
454455
dsx = (nx - 1 - xi) / cx
455456
else:

0 commit comments

Comments
 (0)