0
# Colormap Collections
1
2
CMasher provides 53 scientifically designed colormaps organized by type. All colormaps are perceptually uniform, color-vision deficiency friendly, and available in both normal and reversed versions. Cyclic colormaps also include shifted variants.
3
4
## Capabilities
5
6
### Sequential Colormaps
7
8
Colormaps that transition smoothly from one color to another, ideal for representing ordered data with a natural progression.
9
10
```python { .api }
11
# Available sequential colormaps (37 total)
12
cmrcm.amber # ListedColormap
13
cmrcm.amethyst # ListedColormap
14
cmrcm.apple # ListedColormap
15
cmrcm.arctic # ListedColormap
16
cmrcm.bubblegum # ListedColormap
17
cmrcm.chroma # ListedColormap
18
cmrcm.cosmic # ListedColormap
19
cmrcm.dusk # ListedColormap
20
cmrcm.eclipse # ListedColormap
21
cmrcm.ember # ListedColormap
22
cmrcm.emerald # ListedColormap
23
cmrcm.fall # ListedColormap
24
cmrcm.flamingo # ListedColormap
25
cmrcm.freeze # ListedColormap
26
cmrcm.gem # ListedColormap
27
cmrcm.ghostlight # ListedColormap
28
cmrcm.gothic # ListedColormap
29
cmrcm.horizon # ListedColormap
30
cmrcm.jungle # ListedColormap
31
cmrcm.lavender # ListedColormap
32
cmrcm.lilac # ListedColormap
33
cmrcm.neon # ListedColormap
34
cmrcm.neutral # ListedColormap
35
cmrcm.nuclear # ListedColormap
36
cmrcm.ocean # ListedColormap
37
cmrcm.pepper # ListedColormap
38
cmrcm.rainforest # ListedColormap
39
cmrcm.sapphire # ListedColormap
40
cmrcm.savanna # ListedColormap
41
cmrcm.sepia # ListedColormap
42
cmrcm.sunburst # ListedColormap
43
cmrcm.swamp # ListedColormap
44
cmrcm.torch # ListedColormap
45
cmrcm.toxic # ListedColormap
46
cmrcm.tree # ListedColormap
47
cmrcm.tropical # ListedColormap
48
cmrcm.voltage # ListedColormap
49
```
50
51
#### Usage Example
52
53
```python
54
import matplotlib.pyplot as plt
55
import numpy as np
56
import cmasher.cm as cmrcm
57
58
# Use sequential colormap for heatmap
59
data = np.random.rand(10, 10)
60
plt.imshow(data, cmap=cmrcm.rainforest)
61
plt.colorbar(label='Values')
62
plt.title('Sequential Colormap Example')
63
plt.show()
64
```
65
66
### Diverging Colormaps
67
68
Colormaps with a neutral central color and contrasting colors at the extremes, perfect for data with a meaningful midpoint or zero value.
69
70
```python { .api }
71
# Available diverging colormaps (12 total)
72
cmrcm.fusion # ListedColormap
73
cmrcm.guppy # ListedColormap
74
cmrcm.holly # ListedColormap
75
cmrcm.iceburn # ListedColormap
76
cmrcm.pride # ListedColormap
77
cmrcm.prinsenvlag # ListedColormap
78
cmrcm.redshift # ListedColormap
79
cmrcm.seaweed # ListedColormap
80
cmrcm.viola # ListedColormap
81
cmrcm.waterlily # ListedColormap
82
cmrcm.watermelon # ListedColormap
83
cmrcm.wildfire # ListedColormap
84
```
85
86
#### Usage Example
87
88
```python
89
import matplotlib.pyplot as plt
90
import numpy as np
91
import cmasher.cm as cmrcm
92
93
# Use diverging colormap for correlation matrix
94
data = np.random.randn(10, 10)
95
correlation = np.corrcoef(data)
96
plt.imshow(correlation, cmap=cmrcm.iceburn, vmin=-1, vmax=1)
97
plt.colorbar(label='Correlation')
98
plt.title('Diverging Colormap Example')
99
plt.show()
100
```
101
102
### Cyclic Colormaps
103
104
Colormaps that wrap around seamlessly, suitable for periodic data like angles, phases, or time-of-day.
105
106
```python { .api }
107
# Available cyclic colormaps (4 total)
108
cmrcm.copper # ListedColormap
109
cmrcm.emergency # ListedColormap
110
cmrcm.infinity # ListedColormap
111
cmrcm.seasons # ListedColormap
112
```
113
114
#### Usage Example
115
116
```python
117
import matplotlib.pyplot as plt
118
import numpy as np
119
import cmasher.cm as cmrcm
120
121
# Use cyclic colormap for angular data
122
theta = np.linspace(0, 2*np.pi, 100)
123
r = np.linspace(0, 1, 50)
124
T, R = np.meshgrid(theta, r)
125
data = np.sin(3*T)
126
127
plt.subplot(projection='polar')
128
plt.pcolormesh(T, R, data, cmap=cmrcm.seasons)
129
plt.colorbar(label='Phase')
130
plt.title('Cyclic Colormap Example')
131
plt.show()
132
```
133
134
### Reversed and Shifted Versions
135
136
All colormaps have reversed versions (with `_r` suffix) and cyclic colormaps have shifted versions (with `_s` suffix).
137
138
```python { .api }
139
# Reversed versions
140
cmrcm.rainforest_r # ListedColormap - reversed rainforest
141
cmrcm.iceburn_r # ListedColormap - reversed iceburn
142
cmrcm.seasons_r # ListedColormap - reversed seasons
143
144
# Shifted versions (cyclic only)
145
cmrcm.seasons_s # ListedColormap - shifted seasons
146
cmrcm.copper_s # ListedColormap - shifted copper
147
cmrcm.emergency_s # ListedColormap - shifted emergency
148
cmrcm.infinity_s # ListedColormap - shifted infinity
149
150
# Reversed + shifted versions (cyclic only)
151
cmrcm.seasons_s_r # ListedColormap - reversed shifted seasons
152
cmrcm.copper_s_r # ListedColormap - reversed shifted copper
153
cmrcm.emergency_s_r # ListedColormap - reversed shifted emergency
154
cmrcm.infinity_s_r # ListedColormap - reversed shifted infinity
155
```
156
157
### Colormap Access Patterns
158
159
```python { .api }
160
# Direct access to individual colormaps
161
import cmasher.cm as cmrcm
162
colormap = cmrcm.rainforest
163
164
# Access via matplotlib
165
import matplotlib.pyplot as plt
166
plt.imshow(data, cmap='cmr.rainforest')
167
168
# Access via cmasher utility
169
import cmasher as cmr
170
import matplotlib as mpl
171
colormap = mpl.colormaps['cmr.rainforest']
172
```
173
174
### Colormap Collections
175
176
```python { .api }
177
import cmasher.cm as cmrcm
178
179
# All colormaps dictionary
180
cmrcm.cmap_d: dict[str, ListedColormap]
181
# Dictionary with all colormap objects keyed by name
182
183
# Categorized colormaps dictionary
184
cmrcm.cmap_cd: dict[str, dict[str, ListedColormap]]
185
# Nested dictionary organized by type:
186
# - cmrcm.cmap_cd['sequential']: dict[str, ListedColormap]
187
# - cmrcm.cmap_cd['diverging']: dict[str, ListedColormap]
188
# - cmrcm.cmap_cd['cyclic']: dict[str, ListedColormap]
189
# - cmrcm.cmap_cd['qualitative']: dict[str, ListedColormap]
190
# - cmrcm.cmap_cd['misc']: dict[str, ListedColormap]
191
```
192
193
#### Usage Example
194
195
```python
196
import cmasher.cm as cmrcm
197
198
# Get all sequential colormaps
199
sequential_cmaps = cmrcm.cmap_cd['sequential']
200
print(f"Available sequential colormaps: {len(sequential_cmaps)}")
201
202
# Iterate through all diverging colormaps
203
for name, cmap in cmrcm.cmap_cd['diverging'].items():
204
print(f"Diverging colormap: {name}")
205
206
# Access specific colormap from collection
207
ocean_cmap = cmrcm.cmap_d['ocean']
208
```