Note

Go to the endto download the full example code.

Colormap reference#

Reference for colormaps included with Matplotlib.

A reversed version of each of these colormaps is available by appending_r to the name, as shown inReversed colormaps.

SeeChoosing Colormaps in Matplotlib for an in-depth discussion aboutcolormaps, including colorblind-friendliness, andCreating Colormaps in Matplotlib for a guide to creatingcolormaps.

importmatplotlib.pyplotaspltimportnumpyasnpcmaps=[('Perceptually Uniform Sequential',['viridis','plasma','inferno','magma','cividis']),('Sequential',['Greys','Purples','Blues','Greens','Oranges','Reds','YlOrBr','YlOrRd','OrRd','PuRd','RdPu','BuPu','GnBu','PuBu','YlGnBu','PuBuGn','BuGn','YlGn']),('Sequential (2)',['gray','bone','pink','spring','summer','autumn','winter','cool','Wistia','hot','afmhot','gist_heat','copper']),('Diverging',['PiYG','PRGn','BrBG','PuOr','RdGy','RdBu','RdYlBu','RdYlGn','Spectral','coolwarm','bwr','seismic','berlin','managua','vanimo']),('Cyclic',['twilight','twilight_shifted','hsv']),('Qualitative',['Pastel1','Pastel2','Paired','Accent','Dark2','Set1','Set2','Set3','tab10','tab20','tab20b','tab20c']),('Miscellaneous',['flag','prism','ocean','gist_earth','terrain','gist_stern','gnuplot','gnuplot2','CMRmap','cubehelix','brg','gist_rainbow','rainbow','jet','turbo','nipy_spectral','gist_ncar'])]gradient=np.linspace(0,1,256)gradient=np.vstack((gradient,gradient))defplot_color_gradients(cmap_category,cmap_list):# Create figure and adjust figure height to number of colormapsnrows=len(cmap_list)figh=0.35+0.15+(nrows+(nrows-1)*0.1)*0.22fig,axs=plt.subplots(nrows=nrows,figsize=(6.4,figh))fig.subplots_adjust(top=1-.35/figh,bottom=.15/figh,left=0.2,right=0.99)axs[0].set_title(f"{cmap_category} colormaps",fontsize=14)forax,cmap_nameinzip(axs,cmap_list):ax.imshow(gradient,aspect='auto',cmap=cmap_name)ax.text(-.01,.5,cmap_name,va='center',ha='right',fontsize=10,transform=ax.transAxes)# Turn off *all* ticks & spines, not just the ones with colormaps.foraxinaxs:ax.set_axis_off()forcmap_category,cmap_listincmaps:plot_color_gradients(cmap_category,cmap_list)
  • Perceptually Uniform Sequential colormaps
  • Sequential colormaps
  • Sequential (2) colormaps
  • Diverging colormaps
  • Cyclic colormaps
  • Qualitative colormaps
  • Miscellaneous colormaps

Discouraged

For backward compatibility we additionally support the following colormapnames, which are identical to other builtin colormaps. Their use isdiscouraged. Use the suggested replacement instead.

Colormap

Use identical replacement instead

gist_gray

gray

gist_yarg

gray_r

binary

gray_r

Reversed colormaps#

Append_r to the name of any built-in colormap to get the reversedversion:

plot_color_gradients("Original and reversed ",['viridis','viridis_r'])
Original and reversed  colormaps

The built-in reversed colormaps are generated usingColormap.reversed.For an example, seeReversing a colormap

References

The use of the following functions, methods, classes and modules is shownin this example:

Tags:styling: colormappurpose: reference

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

Gallery generated by Sphinx-Gallery

On this page