Skip to content

Commit 613ea28

Browse files
committed
BUG : fix non-uniform grids in pcolorfast
Closes #4227
1 parent 92c50d1 commit 613ea28

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/matplotlib/image.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,8 +853,9 @@ def make_image(self, magnification=1.0):
853853
l, b, r, t = self.axes.bbox.extents
854854
width = (round(r) + 0.5) - (round(l) - 0.5)
855855
height = (round(t) + 0.5) - (round(b) - 0.5)
856-
width = width * magnification
857-
height = height * magnification
856+
# The extra cast-to-int is only needed for python2
857+
width = int(round(width * magnification))
858+
height = int(round(height * magnification))
858859
if self._rgbacache is None:
859860
A = self.to_rgba(self._A, bytes=True)
860861
self._rgbacache = A

lib/matplotlib/tests/test_axes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3668,6 +3668,17 @@ def test_bar_negative_width():
36683668
assert_equal(b._height, indx + 1)
36693669

36703670

3671+
@cleanup
3672+
def test_pcolor_fast_non_uniform():
3673+
Z = np.arange(6).reshape((3, 2))
3674+
X = np.array([0, 1, 2, 10])
3675+
Y = np.array([0, 1, 2])
3676+
3677+
plt.figure()
3678+
ax = plt.subplot(111)
3679+
ax.pcolorfast(X, Y, Z.T)
3680+
3681+
36713682
if __name__ == '__main__':
36723683
import nose
36733684
import sys

0 commit comments

Comments
 (0)