|
3 | 3 |
|
4 | 4 | .. _colormap-manipulation:
|
5 | 5 |
|
6 |
| -******************************** |
7 |
| -Creating Colormaps in Matplotlib |
8 |
| -******************************** |
| 6 | +****************** |
| 7 | +Creating Colormaps |
| 8 | +****************** |
9 | 9 |
|
10 | 10 | Matplotlib has a number of built-in colormaps accessible via
|
11 | 11 | `.matplotlib.colormaps`. There are also external libraries like
|
12 | 12 | palettable_ that have many extra colormaps.
|
13 | 13 |
|
14 | 14 | .. _palettable: https://jiffyclub.github.io/palettable/
|
15 | 15 |
|
16 |
| -However, we often want to create or manipulate colormaps in Matplotlib. |
| 16 | +However, we may also want to create or manipulate our own colormaps. |
17 | 17 | This can be done using the class `.ListedColormap` or
|
18 | 18 | `.LinearSegmentedColormap`.
|
19 |
| -Seen from the outside, both colormap classes map values between 0 and 1 to |
20 |
| -a bunch of colors. There are, however, slight differences, some of which are |
21 |
| -shown in the following. |
| 19 | +Both colormap classes map values between 0 and 1 to colors. There are however |
| 20 | +differences, as explained below. |
22 | 21 |
|
23 | 22 | Before manually creating or manipulating colormaps, let us first see how we
|
24 | 23 | can obtain colormaps and their colors from existing colormap classes.
|
25 | 24 |
|
26 |
| -
|
27 | 25 | Getting colormaps and accessing their values
|
28 | 26 | ============================================
|
29 | 27 |
|
|
32 | 30 | which returns a colormap object. The length of the list of colors used
|
33 | 31 | internally to define the colormap can be adjusted via `.Colormap.resampled`.
|
34 | 32 | Below we use a modest value of 8 so there are not a lot of values to look at.
|
35 |
| -
|
36 | 33 | """
|
37 | 34 |
|
38 | 35 | import matplotlib.pyplot as plt
|
|
0 commit comments