Load cmap
pypalettes.load_cmap
load_cmap(name='random', cmap_type='discrete', reverse=False, keep_first_n=None, keep_last_n=None, keep=None, repeat=1, shuffle=False)
Load a matplotlib colormap from one of the 2500+ available palettes.
You can find all valid palette names here
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Union[str, List[str]]
|
Name of the palette |
'random'
|
cmap_type
|
str
|
Type of colormap: 'continuous' or 'discrete' |
'discrete'
|
reverse
|
bool
|
Whether to reverse the order of the colors or not |
False
|
keep_first_n
|
Optional[int]
|
Keep only the first n colors of the palette |
None
|
keep
|
Optional[List[bool]]
|
Specify which colors to keep in the palette |
None
|
repeat
|
int
|
The number of times the palette must be present in the output. Used to access larger palettes that are repeated. |
1
|
shuffle
|
Union[bool, int]
|
Used to mix the order of colors. If an integer is supplied, it will be used as the seed. |
False
|
Examples
# mkdocs: render
import matplotlib.pyplot as plt
import numpy as np
from pypalettes import load_cmap
np.random.seed(0)
data = np.random.randn(20, 20)
cmap = load_cmap("Sunset", cmap_type="continuous")
plt.imshow(
X=data,
cmap=cmap
)
plt.colorbar()
# mkdocs: render
import matplotlib.pyplot as plt
import numpy as np
from pypalettes import load_cmap
np.random.seed(0)
data = np.random.randn(20, 20)
cmap = load_cmap("Acadia", cmap_type="continuous")
plt.imshow(
X=data,
cmap=cmap
)
plt.colorbar()