Skip to content

Commit

Permalink
Merge pull request #5109 from Cadair/master
Browse files Browse the repository at this point in the history
Fix for bug in set_cmap in NonUniformImage
  • Loading branch information
WeatherGod committed Sep 21, 2015
2 parents d70ce32 + ad2d4cb commit 2706edb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/matplotlib/image.py
Expand Up @@ -847,12 +847,12 @@ def set_filterrad(self, s):
def set_norm(self, norm):
if self._A is not None:
raise RuntimeError('Cannot change colors after loading data')
super(NonUniformImage, self).set_norm(self, norm)
super(NonUniformImage, self).set_norm(norm)

def set_cmap(self, cmap):
if self._A is not None:
raise RuntimeError('Cannot change colors after loading data')
super(NonUniformImage, self).set_cmap(self, cmap)
super(NonUniformImage, self).set_cmap(cmap)


class PcolorImage(martist.Artist, cm.ScalarMappable):
Expand Down
14 changes: 13 additions & 1 deletion lib/matplotlib/tests/test_image.py
Expand Up @@ -6,7 +6,7 @@
import numpy as np

from matplotlib.testing.decorators import image_comparison, knownfailureif, cleanup
from matplotlib.image import BboxImage, imread
from matplotlib.image import BboxImage, imread, NonUniformImage
from matplotlib.transforms import Bbox
from matplotlib import rcParams
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -441,6 +441,18 @@ def test_zoom_and_clip_upper_origin():
ax.set_xlim(-0.5, 2.0)


@cleanup
def test_nonuniformimage_setcmap():
ax = plt.gca()
im = NonUniformImage(ax)
im.set_cmap('Blues')

@cleanup
def test_nonuniformimage_setnorm():
ax = plt.gca()
im = NonUniformImage(ax)
im.set_norm(plt.Normalize())

if __name__=='__main__':
import nose
nose.runmodule(argv=['-s','--with-doctest'], exit=False)

0 comments on commit 2706edb

Please sign in to comment.