Skip to content

Commit be37304

Browse files
committed
Remove a copy in pcolormesh.
This slightly increases the size of the maximum pcolormesh before hitting a MemoryError. Test with N = 6000; x, y = mgrid[:N, :N]; z = sin(x + y); pcolormesh(x, y, z) The patch raises the maximum N to ~8000 on my system (depending on the load). OTOH, this probably(?) makes pcolormesh sensitive to later changes in the input array.
1 parent b1d9443 commit be37304

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/matplotlib/collections.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,19 +1741,16 @@ def __init__(self, meshWidth, meshHeight, coordinates,
17411741
Collection.__init__(self, **kwargs)
17421742
self._meshWidth = meshWidth
17431743
self._meshHeight = meshHeight
1744-
self._coordinates = coordinates
1744+
# By converting to floats now, we can avoid that on every draw.
1745+
self._coordinates = np.asarray(coordinates, float).reshape(
1746+
(meshHeight + 1, meshWidth + 1, 2))
17451747
self._antialiased = antialiased
17461748
self._shading = shading
17471749

17481750
self._bbox = transforms.Bbox.unit()
17491751
self._bbox.update_from_data_xy(coordinates.reshape(
17501752
((meshWidth + 1) * (meshHeight + 1), 2)))
17511753

1752-
# By converting to floats now, we can avoid that on every draw.
1753-
self._coordinates = self._coordinates.reshape(
1754-
(meshHeight + 1, meshWidth + 1, 2))
1755-
self._coordinates = np.array(self._coordinates, float)
1756-
17571754
def get_paths(self):
17581755
if self._paths is None:
17591756
self.set_paths()

0 commit comments

Comments
 (0)