Skip to content

Commit be216b2

Browse files
committed
Merge pull request #4228 from tacaswell/pcolorfast_nonuniform_fix
BUG : fix non-uniform grids in pcolorfast
2 parents a5e51ca + 8e64eed commit be216b2

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/matplotlib/image.py

+3-2
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

+11
Original file line numberDiff line numberDiff line change
@@ -3675,6 +3675,17 @@ def test_no_None():
36753675
assert_raises(ValueError, plt.plot, None, None)
36763676

36773677

3678+
@cleanup
3679+
def test_pcolor_fast_non_uniform():
3680+
Z = np.arange(6).reshape((3, 2))
3681+
X = np.array([0, 1, 2, 10])
3682+
Y = np.array([0, 1, 2])
3683+
3684+
plt.figure()
3685+
ax = plt.subplot(111)
3686+
ax.pcolorfast(X, Y, Z.T)
3687+
3688+
36783689
if __name__ == '__main__':
36793690
import nose
36803691
import sys

0 commit comments

Comments
 (0)