Python matplotlib.cm.cmap_d() Examples
The following are 2
code examples of matplotlib.cm.cmap_d().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.cm
, or try the search function
.
Example #1
Source File: colormaputil.py From allesfitter with MIT License | 6 votes |
def get_cmap( cmap, name=None, n=256 ): """ in: a name "Blues" "BuGn_r" ... of a builtin cmap (case-sensitive) or a filename, np.loadtxt() n x 3 or 4 ints 0..255 or floats 0..1 or a cmap already or a numpy array. See http://wiki.scipy.org/Cookbook/Matplotlib/Show_colormaps or in IPython, pl.cm.<tab> """ if isinstance( cmap, colors.Colormap ): return cmap if isinstance( cmap, str ): if cmap in cm.cmap_d: return pl.get_cmap( cmap ) # "Blues" ... A = np.loadtxt( cmap, delimiter=None ) # None: white space name = name or cmap.split("/")[-1] .split(".")[0] # .../xx.csv -> xx else: A = cmap # numpy array or array-like return array_cmap( A, name, n=n )
Example #2
Source File: util.py From holoviews with BSD 3-Clause "New" or "Revised" License | 4 votes |
def _list_cmaps(provider=None, records=False): """ List available colormaps by combining matplotlib, bokeh, and colorcet colormaps or palettes if available. May also be narrowed down to a particular provider or list of providers. """ if provider is None: provider = providers elif isinstance(provider, basestring): if provider not in providers: raise ValueError('Colormap provider %r not recognized, must ' 'be one of %r' % (provider, providers)) provider = [provider] cmaps = [] def info(provider,names): return [CMapInfo(name=n,provider=provider,category=None,source=None,bg=None) for n in names] \ if records else list(names) if 'matplotlib' in provider: try: import matplotlib.cm as cm cmaps += info('matplotlib', [cmap for cmap in cm.cmap_d if not (cmap.startswith('cet_') or # duplicates list below cmap.startswith('Vega') or # deprecated in matplotlib=2.1 cmap.startswith('spectral') )]) # deprecated in matplotlib=2.1 except: pass if 'bokeh' in provider: try: from bokeh import palettes cmaps += info('bokeh', palettes.all_palettes) cmaps += info('bokeh', [p+'_r' for p in palettes.all_palettes]) except: pass if 'colorcet' in provider: try: from colorcet import palette_n, glasbey_hv cet_maps = palette_n.copy() cet_maps['glasbey_hv'] = glasbey_hv # Add special hv-specific map cmaps += info('colorcet', cet_maps) cmaps += info('colorcet', [p+'_r' for p in cet_maps]) except: pass return sorted(unique_iterator(cmaps))