9.2.5. Matplotlib colormaps in Nilearn

Visualize HCP connectome workbench color maps shipped with Nilearn which can be used for plotting brain images on surface.

See Surface plotting for surface plotting details.

import numpy as np
import matplotlib.pyplot as plt

from nilearn.plotting.cm import _cmap_d as nilearn_cmaps
from nilearn.plotting import show Plot color maps

nmaps = len(nilearn_cmaps)
a = np.outer(np.arange(0, 1, 0.01), np.ones(10))

# Initialize the figure
plt.figure(figsize=(10, 4.2))
plt.subplots_adjust(top=0.4, bottom=0.05, left=0.01, right=0.99)

for index, cmap in enumerate(nilearn_cmaps):
    plt.subplot(1, nmaps + 1, index + 1)
    plt.imshow(a, cmap=nilearn_cmaps[cmap])
    plt.title(cmap, fontsize=10, va='bottom', rotation=90)
cold_hot, cold_hot_r, cold_white_hot, cold_white_hot_r, brown_blue, brown_blue_r, cyan_copper, cyan_copper_r, cyan_orange, cyan_orange_r, blue_red, blue_red_r, brown_cyan, brown_cyan_r, purple_green, purple_green_r, purple_blue, purple_blue_r, blue_orange, blue_orange_r, black_blue, black_blue_r, black_purple, black_purple_r, black_pink, black_pink_r, black_green, black_green_r, black_red, black_red_r, ocean_hot, ocean_hot_r, hot_white_bone, hot_white_bone_r, hot_black_bone, hot_black_bone_r, bwr, bwr_r, red_transparent, red_transparent_full_alpha_range, green_transparent, green_transparent_full_alpha_range, blue_transparent, blue_transparent_full_alpha_range, roy_big_bl, videen_style Plot matplotlib color maps

plt.figure(figsize=(10, 5))
plt.subplots_adjust(top=0.8, bottom=0.05, left=0.01, right=0.99)
deprecated_cmaps = ['Vega10', 'Vega20', 'Vega20b', 'Vega20c', 'spectral']
m_cmaps = []
for m in plt.cm.datad:
    if not m.endswith("_r") and m not in deprecated_cmaps:

for index, cmap in enumerate(m_cmaps):
    plt.subplot(1, len(m_cmaps) + 1, index + 1)
    plt.imshow(a, cmap=plt.get_cmap(cmap), aspect='auto')
    plt.title(cmap, fontsize=10, va='bottom', rotation=90)

Accent, Blues, BrBG, BuGn, BuPu, CMRmap, Dark2, GnBu, Greens, Greys, OrRd, Oranges, PRGn, Paired, Pastel1, Pastel2, PiYG, PuBu, PuBuGn, PuOr, PuRd, Purples, RdBu, RdGy, RdPu, RdYlBu, RdYlGn, Reds, Set1, Set2, Set3, Spectral, Wistia, YlGn, YlGnBu, YlOrBr, YlOrRd, afmhot, autumn, binary, bone, brg, bwr, cool, coolwarm, copper, cubehelix, flag, gist_earth, gist_gray, gist_heat, gist_ncar, gist_rainbow, gist_stern, gist_yarg, gnuplot, gnuplot2, gray, hot, hsv, jet, nipy_spectral, ocean, pink, prism, rainbow, seismic, spring, summer, tab10, tab20, tab20b, tab20c, terrain, winter

Total running time of the script: ( 0 minutes 1.857 seconds)

Gallery generated by Sphinx-Gallery