Skip to content

Commit be0aed4

Browse files
committed
BUG : fix non-uniform grids in pcolorfast
Closes #4227
1 parent 0346946 commit be0aed4

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/matplotlib/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,8 @@ def make_image(self, magnification=1.0):
852852
l, b, r, t = self.axes.bbox.extents
853853
width = (round(r) + 0.5) - (round(l) - 0.5)
854854
height = (round(t) + 0.5) - (round(b) - 0.5)
855-
width = width * magnification
856-
height = height * magnification
855+
width = int(width * magnification)
856+
height = int(height * magnification)
857857
if self._rgbacache is None:
858858
A = self.to_rgba(self._A, bytes=True)
859859
self._rgbacache = A

lib/matplotlib/tests/test_axes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3565,6 +3565,18 @@ def test_move_offsetlabel():
35653565
ax.yaxis.tick_right()
35663566
assert_equal((1, 0.5), ax.yaxis.offsetText.get_position())
35673567

3568+
3569+
@cleanup
3570+
def test_pcolor_fast_non_uniform():
3571+
Z = np.arange(6).reshape((3, 2))
3572+
X = np.array([0, 1, 2, 10])
3573+
Y = np.array([0, 1, 2])
3574+
3575+
plt.figure()
3576+
ax = plt.subplot(111)
3577+
ax.pcolorfast(X, Y, Z.T) # <-- fails
3578+
3579+
35683580
if __name__ == '__main__':
35693581
import nose
35703582
import sys

0 commit comments

Comments
 (0)