From dbc432499a4973ea5a40496fa22ac1796c099e2b Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Thu, 22 Mar 2012 11:52:45 -0400 Subject: [PATCH] Fix streamplot for non-square grids. * Order of x/y was switched. * Additional cleanup (remove unused import and old comment, improve docstring). --- lib/matplotlib/streamplot.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/streamplot.py b/lib/matplotlib/streamplot.py index b156f6cb53a2..c70eb76edda7 100644 --- a/lib/matplotlib/streamplot.py +++ b/lib/matplotlib/streamplot.py @@ -5,7 +5,6 @@ import numpy as np import matplotlib import matplotlib.patches as patches -import matplotlib.cbook as cbook __all__ = ['streamplot'] @@ -332,9 +331,11 @@ def backward_time(xi, yi): return -dxi, -dyi def integrate(x0, y0): - """Return x, y coordinates of trajectory based on starting point. + """Return x, y grid-coordinates of trajectory based on starting point. + + Integrate both forward and backward in time from starting point in + grid coordinates. - Integrate both forward and backward in time from starting point. Integration is terminated when a trajectory reaches a domain boundary or when it crosses into an already occupied cell in the StreamMask. The resulting trajectory is None if it is shorter than `minlength`. @@ -446,10 +447,10 @@ def _integrate_rk12(x0, y0, dmap, f): def _euler_step(xf_traj, yf_traj, dmap, f): """Simple Euler integration step.""" - nx, ny = dmap.grid.shape + ny, nx = dmap.grid.shape xi = xf_traj[-1] yi = yf_traj[-1] - cx, cy = f(xi, yi) # ds.cx is in data coordinates, ds in axis coord. + cx, cy = f(xi, yi) if cx > 0: dsx = (nx - 1 - xi) / cx else: