Skip to content

Commit

Permalink
BUG : fix non-uniform grids in pcolorfast
Browse files Browse the repository at this point in the history
Closes #4227
  • Loading branch information
tacaswell committed Apr 19, 2015
1 parent 92c50d1 commit 613ea28
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/matplotlib/image.py
Expand Up @@ -853,8 +853,9 @@ def make_image(self, magnification=1.0):
l, b, r, t = self.axes.bbox.extents
width = (round(r) + 0.5) - (round(l) - 0.5)
height = (round(t) + 0.5) - (round(b) - 0.5)
width = width * magnification
height = height * magnification
# The extra cast-to-int is only needed for python2
width = int(round(width * magnification))
height = int(round(height * magnification))
if self._rgbacache is None:
A = self.to_rgba(self._A, bytes=True)
self._rgbacache = A
Expand Down
11 changes: 11 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Expand Up @@ -3668,6 +3668,17 @@ def test_bar_negative_width():
assert_equal(b._height, indx + 1)


@cleanup
def test_pcolor_fast_non_uniform():
Z = np.arange(6).reshape((3, 2))
X = np.array([0, 1, 2, 10])
Y = np.array([0, 1, 2])

plt.figure()
ax = plt.subplot(111)
ax.pcolorfast(X, Y, Z.T)


if __name__ == '__main__':
import nose
import sys
Expand Down

0 comments on commit 613ea28

Please sign in to comment.