Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ff5e81

Browse files
committed
Fix custom scales in pcolormesh (thanks, Matthew Turk)
svn path=/trunk/matplotlib/; revision=5716
1 parent e00f5ed commit 7ff5e81

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

examples/pylab_examples/quadmesh_demo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
ax = fig.add_subplot(121)
3030
ax.set_axis_bgcolor("#bdb76b")
3131
ax.pcolormesh(Qx,Qz,Z)
32+
ax.set_xscale('log')
33+
ax.set_yscale('log')
3234
ax.set_title('Without masked values')
3335

3436
ax = fig.add_subplot(122)

lib/matplotlib/collections.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,14 +512,24 @@ def draw(self, renderer):
512512
if clippath_trans is not None:
513513
clippath_trans = clippath_trans.frozen()
514514

515-
assert transform.is_affine
515+
if not transform.is_affine:
516+
coordinates = self._coordinates.reshape(
517+
(self._coordinates.shape[0] *
518+
self._coordinates.shape[1],
519+
2))
520+
coordinates = transform.transform(coordinates)
521+
coordinates = coordinates.reshape(self._coordinates.shape)
522+
transform = transforms.IdentityTransform()
523+
else:
524+
coordinates = self._coordinates
525+
516526
if not transOffset.is_affine:
517527
offsets = transOffset.transform_non_affine(offsets)
518528
transOffset = transOffset.get_affine()
519529

520530
renderer.draw_quad_mesh(
521531
transform.frozen(), self.clipbox, clippath, clippath_trans,
522-
self._meshWidth, self._meshHeight, self._coordinates,
532+
self._meshWidth, self._meshHeight, coordinates,
523533
offsets, transOffset, self._facecolors, self._antialiased,
524534
self._showedges)
525535
renderer.close_group(self.__class__.__name__)

0 commit comments

Comments
 (0)