diff --git a/python/lsst/display/matplotlib/matplotlib.py b/python/lsst/display/matplotlib/matplotlib.py index e032c7b..b24c7cd 100644 --- a/python/lsst/display/matplotlib/matplotlib.py +++ b/python/lsst/display/matplotlib/matplotlib.py @@ -97,6 +97,7 @@ def __init__(self, display, verbose=False, interpretMaskBits=True, mtvOrigin=afw self._interpretMaskBits = interpretMaskBits # interpret mask bits in mtv self._mtvOrigin = mtvOrigin self._mappable = None + self._image_colormap = pyplot.cm.gray # self.__alpha = unicodedata.lookup("GREEK SMALL LETTER alpha") # used in cursor display string self.__delta = unicodedata.lookup("GREEK SMALL LETTER delta") # used in cursor display string @@ -148,6 +149,16 @@ def show_colorbar(self, show=True): if show: if self._mappable: self._figure.colorbar(self._mappable) + + def _setImageColormap(self, cmap): + """Set the colormap used for th eimage""" + self._image_colormap = cmap + + # This will eventually be moved into Display + def setImageColormap(self, cmap): + """Set the colormap used for th eimage""" + self._setImageColormap(cmap) + # # Defined API # @@ -279,7 +290,7 @@ def _i_mtv(self, data, wcs, title, isMask): cmap = mpColors.ListedColormap(colors) norm = mpColors.NoNorm() else: - cmap = pyplot.cm.gray + cmap = self._image_colormap norm = self._normalize ax = self._figure.gca() diff --git a/tests/test_display_matplotlib.py b/tests/test_display_matplotlib.py index 6623e13..05e882a 100644 --- a/tests/test_display_matplotlib.py +++ b/tests/test_display_matplotlib.py @@ -38,6 +38,17 @@ def testSetAfwDisplayBackend(self): """Set the default backend to this package""" afwDisplay.setDefaultBackend("matplotlib") + def testSetImageColormap(self): + """This is a stand-in for an eventual testcase for changing image colormap + The basic outline should look something like: + + afwDisplay.setDefaultBackend("matplotlib") + display = afwDisplay.Display() + display.setImageColormap('viridis') + assert display._image_colormap == 'viridis' + """ + pass + class TestMemory(lsst.utils.tests.MemoryTestCase): pass