TNO Intern

Commit d45fd378 authored by Arjo Segers's avatar Arjo Segers
Browse files

Support colormaps from `cmcrameri` module.

parent fd8bd893
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@
#   By default plot country borders.
#   Made facecolor of lakes transparant.
#
# 2024-09, Arjo Segers
#   Support colormaps from `cmcrameri` module.
#

########################################################################
###
@@ -516,6 +519,10 @@ class ColorbarFigure(Figure):
            * 'bwr'  (blue-white-red)
            * 'pwb'  (purple-white-brown)

          * colormaps from :py:mod:`cmcrameri` module::

              'cmcrameri.cm.navia_r'

          * predefined colormaps : 'jet', ...

        * ``color_under``   : color descriptions for underflow
@@ -664,13 +671,21 @@ class ColorbarFigure(Figure):

        else:
            # get predefined colormap:
            if colors.startswith("cmcrameri.cm"):
                import cmcrameri
                self.cmap = getattr(cmcrameri.cm,colors.lstrip("cmcrameri.cm."))
            else :
                self.cmap = matplotlib.pyplot.get_cmap(colors)
            # endif

        # endif

        # boundaries:
        if color_under is not None :
            self.cmap.set_under(color_under)
        if color_over is not None :
            self.cmap.set_over(color_over)
        if color_bad is not None :
            self.cmap.set_bad(color_bad)

    # enddef  # Set_ColorMap