Skip to content Skip to sidebar Skip to footer

How To Install Colormap Using Pip For Spyder (python 3.5) On Windows

I want to use cmap_builder, So I tried from colormap import cmap_builder. When I tried, Spyder throwed me an error ImportError: No module named 'colormap' So I tried installing, pi

Solution 1:

In principle matplotlib already has all the tools available to create custom colormaps. The two main options are to create a segmented colormap, LinearSegmentedColormap or a discrete colormap ListedColormap.

Find here an example of a continuous colormap between crimson, gold and blue:

import matplotlib.colorsas mcolors
import matplotlib.pyplotas plt
import numpy as np

cmap = mcolors.LinearSegmentedColormap.from_list("n", ["crimson", "gold","steelblue"])

x = np.linspace(-1,2.7)
X,Y = np.meshgrid(x,x)
Z = np.exp(-X**2-Y**2)

im =plt.imshow(Z, cmap=cmap)
plt.colorbar()

plt.show()

enter image description here

A discrete colormap could be created like this:

cmap = mcolors.ListedColormap(["crimson", "gold","steelblue"])

enter image description here

Post a Comment for "How To Install Colormap Using Pip For Spyder (python 3.5) On Windows"