8000 Fix streamline plotting from upper edges of grid · matplotlib/matplotlib@fb9289b · GitHub
[go: up one dir, main page]

Skip to content

Commit fb9289b

Browse files
committed
Fix streamline plotting from upper edges of grid
1 parent 59732ac commit fb9289b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/matplotlib/streamplot.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
171171

172172
for xs, ys in sp2:
173173
xg, yg = dmap.data2grid(xs, ys)
174+
# Floating point issues can cause xg, yg to be slightly out of
175+
# bounds for xs, ys on the upper boundaries. Because we have
176+
# already checked that the starting points are within the original
177+
# grid, clip the xg, yg to the grid to work around this issue
178+
xg = np.clip(xg, 0, grid.nx - 1)
179+
yg = np.clip(yg, 0, grid.ny - 1)
180+
174181
t = integrate(xg, yg)
175182
if t is not None:
176183
trajectories.append(t)

0 commit comments

Comments
 (0)
0