8000 Consistent grid sizes in streamplot. Closes #2653. · matplotlib/matplotlib@e8f035d · GitHub
[go: up one dir, main page]

Skip to content

Commit e8f035d

Browse files
committed
Consistent grid sizes in streamplot. Closes #2653.
1 parent 263c1b9 commit e8f035d

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2013-12-30 Made streamplot grid size consistent for different types of density
2+
argument. A 30x30 grid is now used for both density=1 and
3+
density=(1, 1).
4+
15
2013-11-28 Added qhull extension module to perform Delaunay triangulation more
26
robustly than before. It is used by tri.Triangulation (and hence
37
all pyplot.tri* methods) and mlab.griddata. Deprecated

doc/users/whats_new.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ Added `FormatStrFormatterNewStyle` which does the same job as
7474
`FormatStrFormatter`, but accepts new-style formatting strings
7575
instead of printf-style formatting strings
7676

77+
Consistent grid sizes in streamplots
78+
````````````````````````````````````
79+
:func:`~matplotlib.pyplot.streamplot` uses a base grid size of 30x30 for both
80+
`density=1` and `density=(1, 1)`. Previously a grid size of 30x30 was used for
81+
`density=1`, but a grid size of 25x25 was used for `density=(1, 1)`.
82+
83+
7784
Date handling
7885
-------------
7986

lib/matplotlib/streamplot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
3131
the number of columns should match x.
3232
*density* : float or 2-tuple
3333
Controls the closeness of streamlines. When `density = 1`, the domain
34-
is divided into a 25x25 grid---*density* linearly scales this grid.
34+
is divided into a 30x30 grid---*density* linearly scales this grid.
3535
Each cell in the grid can have, at most, one traversing streamline.
3636
For different densities in each direction, use [density_x, density_y].
3737
*linewidth* : numeric or 2d array
@@ -313,8 +313,8 @@ def __init__(self, density):
313313
self.nx = self.ny = int(30 * density)
314314
else:
315315
assert len(density) == 2
316-
self.nx = int(25 * density[0])
317-
self.ny = int(25 * density[1])
316+
self.nx = int(30 * density[0])
317+
self.ny = int(30 * density[1])
318318
self._mask = np.zeros((self.ny, self.nx))
319319
self.shape = self._mask.shape
320320

lib/matplotlib/tests/test_streamplot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ def test_linewidth():
2828
X, Y, U, V = velocity_field()
2929
speed = np.sqrt(U*U + V*V)
3030
lw = 5*speed/speed.max()
31-
plt.streamplot(X, Y, U, V, density=[0.5, 1], color='k', linewidth=lw)
31+
df = 25. / 30. # Compatibility factor for old test image
32+
plt.streamplot(X, Y, U, V, density=[0.5 * df, 1. * df], color='k',
33+
linewidth=lw)
3234

3335

3436
@image_comparison(baseline_images=['streamplot_masks_and_nans_test_image'])

lib/matplotlib/tests/test_transforms.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ def test_pre_transform_plotting():
102102
u = 2*np.sin(x) + np.cos(y[:, np.newaxis])
103103
v = np.sin(x) - np.cos(y[:, np.newaxis])
104104

105+
df = 25. / 30. # Compatibility factor for old test image
105106
ax.streamplot(x, y, u, v, transform=times10 + ax.transData,
106-
density=(1, 1), linewidth=u**2 + v**2)
107+
density=(df, df), linewidth=u**2 + v**2)
107108

108109
# reduce the vector data down a bit for barb and quiver plotting
109110
x, y = x[::3], y[::3]

0 commit comments

Comments
 (0)
0