Colormap Reference#

FanInSAR provides four well-known colormap categories, including:

  • SCM: Scientific Colour Maps (SCM) is a set of perceptually uniform and color-vision deficiency friendly palettes designed for scientific visualization. These color maps ensure that visual errors are minimized, preventing distortion of underlying data and misleading the reader. (See here for more information.)

  • GMT: Colormaps from the Generic Mapping Tools (GMT) software package. (See here for more information.)

  • cmocean: cmocean contains colormaps for commonly-used oceanographic variables. Most of the colormaps started from matplotlib colormaps, but have now been adjusted using the viscm tool to be perceptually uniform.(See here for more information.)

  • colorcet: A collection of perceptually accurate 256-color colormaps for use with Python plotting programs like Bokeh, Matplotlib, HoloViews, and Datashader. (See here for more information.)

Usage#

In FanInSAR, the colormap can be accessed by attributes of faninsar.cmaps module. For example, to use the earth colormap of GMT, you can use the following code:

from faninsar import cmaps

cmaps.GMT.earth
earth
earth colormap
under
bad
over

Or directly use the colormap name as the attribute of cmaps

cmaps.earth
earth
earth colormap
under
bad
over

Like common colormaps, the colormaps in FanInSAR can be reversed by appending _r to the name of any built-in colormap. For example, to use the reversed earth colormap of GMT, you can use the following code:

cmaps.earth_r
earth_r
earth_r colormap
under
bad
over

You can use the colormap in FanInSAR as the same as the colormaps in Matplotlib. For example, to use the earth colormap of GMT in Matplotlib, you can use the following code:

import matplotlib.pyplot as plt
import numpy as np

np.random.seed(0)
arr = np.random.rand(10, 10)
plt.imshow(arr, cmap=cmaps.earth)
plt.colorbar()
<matplotlib.colorbar.Colorbar at 0x30eb4ab90>
../_images/dac0b25357b9c84741ae74da2eb093b4cac61277eeb95db540569d29bfc6f43a.png

Colormap list#

The following table lists all the colormaps available in FanInSAR.

print(cmaps.names)
['RdGyBu', 'acton', 'bam', 'bamako', 'bamO', 'batlow', 'batlowK', 'batlowW', 'berlin', 'bilbao', 'broc', 'brocO', 'buda', 'bukavu', 'cork', 'corkO', 'davos', 'devon', 'fes', 'glasgow', 'grayC', 'hawaii', 'imola', 'lajolla', 'lapaz', 'lisbon', 'lipari', 'managua', 'navia', 'nuuk', 'oleron', 'oslo', 'roma', 'romaO', 'tofino', 'tokyo', 'turku', 'vanimo', 'vik', 'vikO', 'acton_r', 'bam_r', 'bamako_r', 'bamO_r', 'batlow_r', 'batlowK_r', 'batlowW_r', 'berlin_r', 'bilbao_r', 'broc_r', 'brocO_r', 'buda_r', 'bukavu_r', 'cork_r', 'corkO_r', 'davos_r', 'devon_r', 'fes_r', 'glasgow_r', 'grayC_r', 'hawaii_r', 'imola_r', 'lajolla_r', 'lapaz_r', 'lisbon_r', 'lipari_r', 'managua_r', 'navia_r', 'nuuk_r', 'oleron_r', 'oslo_r', 'roma_r', 'romaO_r', 'tofino_r', 'tokyo_r', 'turku_r', 'vanimo_r', 'vik_r', 'vikO_r', 'abyss', 'bathy', 'cool', 'copper', 'cubhelix', 'cyclic', 'dem1', 'dem2', 'dem3', 'dem4', 'drywet', 'earth', 'elevation', 'etopo1', 'geo', 'globe', 'gray', 'haxby', 'hot', 'inferno', 'jet', 'magma', 'nighttime', 'no_green', 'ocean', 'plasma', 'polar', 'rainbow', 'red2green', 'relief', 'seafloor', 'sealand', 'seis', 'split', 'srtm', 'terra', 'topo', 'turbo', 'viridis', 'world', 'wysiwyg', 'abyss_r', 'bathy_r', 'cool_r', 'copper_r', 'cubhelix_r', 'cyclic_r', 'dem1_r', 'dem2_r', 'dem3_r', 'dem4_r', 'drywet_r', 'earth_r', 'elevation_r', 'etopo1_r', 'geo_r', 'globe_r', 'gray_r', 'haxby_r', 'hot_r', 'inferno_r', 'jet_r', 'magma_r', 'nighttime_r', 'no_green_r', 'ocean_r', 'plasma_r', 'polar_r', 'rainbow_r', 'red2green_r', 'relief_r', 'seafloor_r', 'sealand_r', 'seis_r', 'split_r', 'srtm_r', 'terra_r', 'topo_r', 'turbo_r', 'viridis_r', 'world_r', 'wysiwyg_r', 'algae', 'amp', 'balance', 'curl', 'deep', 'delta', 'dense', 'diff', 'gray', 'haline', 'ice', 'matter', 'oxy', 'phase', 'rain', 'solar', 'speed', 'tarn', 'tempo', 'thermal', 'topo', 'turbid', 'algae_r', 'amp_r', 'balance_r', 'curl_r', 'deep_r', 'delta_r', 'dense_r', 'diff_r', 'gray_r', 'haline_r', 'ice_r', 'matter_r', 'oxy_r', 'phase_r', 'rain_r', 'solar_r', 'speed_r', 'tarn_r', 'tempo_r', 'thermal_r', 'topo_r', 'turbid_r', 'colorwheel', 'bkr', 'bky', 'bwy', 'cwr', 'coolwarm', 'gwv', 'bjy', 'isolum', 'bgy', 'bgyw', 'kbc', 'blues', 'bmw', 'bmy', 'kgy', 'gray', 'dimgray', 'fire', 'kb', 'kg', 'kr', 'rainbow', 'colorwheel_r', 'bkr_r', 'bky_r', 'bwy_r', 'cwr_r', 'coolwarm_r', 'gwv_r', 'bjy_r', 'isolum_r', 'bgy_r', 'bgyw_r', 'kbc_r', 'blues_r', 'bmw_r', 'bmy_r', 'kgy_r', 'gray_r', 'dimgray_r', 'fire_r', 'kb_r', 'kg_r', 'kr_r', 'rainbow_r']

or get a categories list by:

print(cmaps.GMT.names)
['abyss', 'bathy', 'cool', 'copper', 'cubhelix', 'cyclic', 'dem1', 'dem2', 'dem3', 'dem4', 'drywet', 'earth', 'elevation', 'etopo1', 'geo', 'globe', 'gray', 'haxby', 'hot', 'inferno', 'jet', 'magma', 'nighttime', 'no_green', 'ocean', 'plasma', 'polar', 'rainbow', 'red2green', 'relief', 'seafloor', 'sealand', 'seis', 'split', 'srtm', 'terra', 'topo', 'turbo', 'viridis', 'world', 'wysiwyg', 'abyss_r', 'bathy_r', 'cool_r', 'copper_r', 'cubhelix_r', 'cyclic_r', 'dem1_r', 'dem2_r', 'dem3_r', 'dem4_r', 'drywet_r', 'earth_r', 'elevation_r', 'etopo1_r', 'geo_r', 'globe_r', 'gray_r', 'haxby_r', 'hot_r', 'inferno_r', 'jet_r', 'magma_r', 'nighttime_r', 'no_green_r', 'ocean_r', 'plasma_r', 'polar_r', 'rainbow_r', 'red2green_r', 'relief_r', 'seafloor_r', 'sealand_r', 'seis_r', 'split_r', 'srtm_r', 'terra_r', 'topo_r', 'turbo_r', 'viridis_r', 'world_r', 'wysiwyg_r']
gradient = np.linspace(0, 1, 256)
gradient = np.vstack((gradient, gradient))


def plot_color_gradients(cmap_category, cmap_list):
    # Create figure and adjust figure height to number of colormaps
    nrows = len(cmap_list)
    figh = 0.35 + 0.15 + (nrows + (nrows - 1) * 0.1) * 0.22
    fig, axs = plt.subplots(nrows=nrows, figsize=(6.4, figh))
    fig.subplots_adjust(top=1 - 0.35 / figh, bottom=0.15 / figh, left=0.2, right=0.99)

    axs[0].set_title(f"{cmap_category} colormaps", fontsize=14)

    for ax, cmap_name in zip(axs, cmap_list):
        ax.imshow(gradient, aspect="auto", cmap=getattr(cmaps, cmap_name))
        ax.text(-0.01, 0.5, cmap_name, va="center", ha="right", fontsize=10, transform=ax.transAxes)

    # Turn off *all* ticks & spines, not just the ones with colormaps.
    for ax in axs:
        ax.set_axis_off()

SCM colormaps#

plot_color_gradients("SCM", cmaps.SCM.names)
print(cmaps.SCM.names)
['acton', 'bam', 'bamako', 'bamO', 'batlow', 'batlowK', 'batlowW', 'berlin', 'bilbao', 'broc', 'brocO', 'buda', 'bukavu', 'cork', 'corkO', 'davos', 'devon', 'fes', 'glasgow', 'grayC', 'hawaii', 'imola', 'lajolla', 'lapaz', 'lisbon', 'lipari', 'managua', 'navia', 'nuuk', 'oleron', 'oslo', 'roma', 'romaO', 'tofino', 'tokyo', 'turku', 'vanimo', 'vik', 'vikO', 'acton_r', 'bam_r', 'bamako_r', 'bamO_r', 'batlow_r', 'batlowK_r', 'batlowW_r', 'berlin_r', 'bilbao_r', 'broc_r', 'brocO_r', 'buda_r', 'bukavu_r', 'cork_r', 'corkO_r', 'davos_r', 'devon_r', 'fes_r', 'glasgow_r', 'grayC_r', 'hawaii_r', 'imola_r', 'lajolla_r', 'lapaz_r', 'lisbon_r', 'lipari_r', 'managua_r', 'navia_r', 'nuuk_r', 'oleron_r', 'oslo_r', 'roma_r', 'romaO_r', 'tofino_r', 'tokyo_r', 'turku_r', 'vanimo_r', 'vik_r', 'vikO_r']
../_images/16b8a72a64d7817bb69a9933e4c02afc42333d4069e78ef73a4c80c16812e3e8.png

GMT colormaps#

plot_color_gradients("GMT", cmaps.GMT.names)
print(cmaps.GMT.names)
['abyss', 'bathy', 'cool', 'copper', 'cubhelix', 'cyclic', 'dem1', 'dem2', 'dem3', 'dem4', 'drywet', 'earth', 'elevation', 'etopo1', 'geo', 'globe', 'gray', 'haxby', 'hot', 'inferno', 'jet', 'magma', 'nighttime', 'no_green', 'ocean', 'plasma', 'polar', 'rainbow', 'red2green', 'relief', 'seafloor', 'sealand', 'seis', 'split', 'srtm', 'terra', 'topo', 'turbo', 'viridis', 'world', 'wysiwyg', 'abyss_r', 'bathy_r', 'cool_r', 'copper_r', 'cubhelix_r', 'cyclic_r', 'dem1_r', 'dem2_r', 'dem3_r', 'dem4_r', 'drywet_r', 'earth_r', 'elevation_r', 'etopo1_r', 'geo_r', 'globe_r', 'gray_r', 'haxby_r', 'hot_r', 'inferno_r', 'jet_r', 'magma_r', 'nighttime_r', 'no_green_r', 'ocean_r', 'plasma_r', 'polar_r', 'rainbow_r', 'red2green_r', 'relief_r', 'seafloor_r', 'sealand_r', 'seis_r', 'split_r', 'srtm_r', 'terra_r', 'topo_r', 'turbo_r', 'viridis_r', 'world_r', 'wysiwyg_r']
../_images/d9ba0545a6781193501083c8eb48119b892eb6f12728758244e9c20d0a639fff.png

cmocean colormaps#

plot_color_gradients("cmocean", cmaps.cmocean.names)
print(cmaps.cmocean.names)
['algae', 'amp', 'balance', 'curl', 'deep', 'delta', 'dense', 'diff', 'gray', 'haline', 'ice', 'matter', 'oxy', 'phase', 'rain', 'solar', 'speed', 'tarn', 'tempo', 'thermal', 'topo', 'turbid', 'algae_r', 'amp_r', 'balance_r', 'curl_r', 'deep_r', 'delta_r', 'dense_r', 'diff_r', 'gray_r', 'haline_r', 'ice_r', 'matter_r', 'oxy_r', 'phase_r', 'rain_r', 'solar_r', 'speed_r', 'tarn_r', 'tempo_r', 'thermal_r', 'topo_r', 'turbid_r']
../_images/6f2406a0b58fbb031af9dbdcb0422d2fc33967db8e2d90bce50d38ee790bf18c.png

colorcet colormaps#

plot_color_gradients("colorcet", cmaps.colorcet.names)
print(cmaps.colorcet.names)
['colorwheel', 'bkr', 'bky', 'bwy', 'cwr', 'coolwarm', 'gwv', 'bjy', 'isolum', 'bgy', 'bgyw', 'kbc', 'blues', 'bmw', 'bmy', 'kgy', 'gray', 'dimgray', 'fire', 'kb', 'kg', 'kr', 'rainbow', 'colorwheel_r', 'bkr_r', 'bky_r', 'bwy_r', 'cwr_r', 'coolwarm_r', 'gwv_r', 'bjy_r', 'isolum_r', 'bgy_r', 'bgyw_r', 'kbc_r', 'blues_r', 'bmw_r', 'bmy_r', 'kgy_r', 'gray_r', 'dimgray_r', 'fire_r', 'kb_r', 'kg_r', 'kr_r', 'rainbow_r']
../_images/d16e622a20f6d857700ef767e2276f0db60ecbcf051ab2e3cecfe67489c3aba9.png