Skip to content

Instantly share code, notes, and snippets.

@d-v-b
Created October 3, 2015 21:36
Show Gist options
  • Save d-v-b/9e37d13ecc4ab162c35c to your computer and use it in GitHub Desktop.
Save d-v-b/9e37d13ecc4ab162c35c to your computer and use it in GitHub Desktop.
plot an image with all matplotlib cmaps
# test all matplotlib colormaps for a given image
# the image to plot
toPlot = vol[-1]
fName = '/Users/bennettd/Dropbox/media/imag/all_mpl_cmaps.png'
cmaps = 'Spectral, summer, coolwarm, Wistia_r, pink_r, Set1, Set2, Set3, brg_r, Dark2, prism, PuOr_r, afmhot_r, terrain_r, PuBuGn_r, RdPu, gist_ncar_r, gist_yarg_r, Dark2_r, YlGnBu, RdYlBu, hot_r, gist_rainbow_r, gist_stern, PuBu_r, cool_r, cool, gray, copper_r, Greens_r, GnBu, gist_ncar, spring_r, gist_rainbow, gist_heat_r, Wistia, OrRd_r, CMRmap, bone, gist_stern_r, RdYlGn, Pastel2_r, spring, terrain, YlOrRd_r, Set2_r, winter_r, PuBu, RdGy_r, spectral, rainbow, flag_r, jet_r, RdPu_r, gist_yarg, BuGn, Paired_r, hsv_r, bwr, cubehelix, Greens, PRGn, gist_heat, spectral_r, Paired, hsv, Oranges_r, prism_r, Pastel2, Pastel1_r, Pastel1, gray_r, jet, Spectral_r, gnuplot2_r, gist_earth, YlGnBu_r, copper, gist_earth_r, Set3_r, OrRd, gnuplot_r, ocean_r, brg, gnuplot2, PuRd_r, bone_r, BuPu, Oranges, RdYlGn_r, PiYG, CMRmap_r, YlGn, binary_r, gist_gray_r, Accent, BuPu_r, gist_gray, flag, bwr_r, RdBu_r, BrBG, Reds, Set1_r, summer_r, GnBu_r, BrBG_r, Reds_r, RdGy, PuRd, Accent_r, Blues, autumn_r, autumn, cubehelix_r, nipy_spectral_r, ocean, PRGn_r, Greys_r, pink, binary, winter, gnuplot, RdYlBu_r, hot, YlOrBr, coolwarm_r, rainbow_r, Purples_r, PiYG_r, YlGn_r, Blues_r, YlOrBr_r, seismic, Purples, seismic_r, RdBu, Greys, BuGn_r, YlOrRd, PuOr, PuBuGn, nipy_spectral, afmhot'
cmaps = cmaps.split(',')
cmaps = [cm.strip() for cm in cmaps]
n_plots = len(cmaps)
n_plots_x = 12
n_plots_y = n_plots / n_lots_x
plt.figure(figsize=(6 * plots_x, 6*plots_y))
for ind, cm in enumerate(cmaps):
plt.subplot(n_plots_y, n_plots_x, ind+1)
plt.imshow(toPlot, cmap=cm, interpolation = 'None')
plt.axis('off')
plt.title(cm)
plt.tight_layout()
plt.savefig(fName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment