1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
# cmyt
[](https://pypi.org/project/cmyt)
[](https://anaconda.org/conda-forge/cmyt)
[](https://github.com/yt-project/cmyt/actions/workflows/ci.yml)
[](https://github.com/yt-project/cmyt/actions/workflows/bleeding-edge.yaml)
[](https://results.pre-commit.ci/latest/github/yt-project/cmyt/main)
[](https://yt-project.org)
[](https://github.com/charliermarsh/ruff)
<a href="http://yt-project.org"><img src="https://raw.githubusercontent.com/yt-project/yt/main/doc/source/_static/yt_logo.png" width="150"></a>
Matplotlib colormaps from the yt project !
## Colormaps overview
The following colormaps, as well as their respective reversed (`*_r`) versions are available
### Perceptually uniform sequential colormaps
<p align="center">
<img src="https://raw.githubusercontent.com/yt-project/cmyt/main/doc/overview_perceptually_uniform.png" width="800"></a>
</p>
### Monochromatic sequential colormaps
<p align="center">
<img src="https://raw.githubusercontent.com/yt-project/cmyt/main/doc/overview_pixel.png" width="800"></a>
</p>
### Miscellaneous
<p align="center">
<img src="https://raw.githubusercontent.com/yt-project/cmyt/main/doc/overview_misc.png" width="800"></a>
</p>
## Installation
with `pip`
```shell
python -m pip install cmyt
```
or with `conda`
```shell
conda install -c conda-forge cmyt
```
## Usage
cmyt integrates with matplotlib in a similar fashion to
[cmocean](https://matplotlib.org/cmocean/) or
[cmasher](https://cmasher.readthedocs.io)
```python
import numpy as np
import matplotlib.pyplot as plt
import cmyt # that's it !
# generate example data
prng = np.random.RandomState(0x4D3D3D3)
noise = prng.random_sample((100, 100))
x, y = np.mgrid[-50:50, -50:50]
z = 5 * np.exp(-(x**2 + y**2) / 1000)
# setup the figure
fig, ax = plt.subplots()
ax.set(aspect="equal")
# now we can refer to cmyt colormaps as strings
im = ax.pcolormesh(x, y, z + noise, cmap="cmyt.arbre", shading="flat")
fig.colorbar(im, ax=ax)
```
<p align="center">
<img src="https://raw.githubusercontent.com/yt-project/cmyt/main/doc/demo.png" width="400"></a>
</p>
```python
# alternatively, cmyt maps can also be imported as objects
from cmyt import pastel
fig, ax = plt.subplots()
ax.set(aspect="equal")
im = ax.contourf(x, y, z + noise, cmap=pastel)
fig.colorbar(im, ax=ax)
```
<p align="center">
<img src="https://raw.githubusercontent.com/yt-project/cmyt/main/doc/demo_alt.png" width="400"></a>
</p>
A gallery of comparable examples using all colormaps from cmyt is available [in the test directory](https://github.com/yt-project/cmyt/tree/main/tests/baseline).
|