cmweather
raw JSON → 0.3.2 verified Mon Apr 27 auth: no python
cmweather provides colormaps for weather and climate data visualization, with many color vision deficiency (CVD) friendly options. Current version 0.3.2, requires Python >=3.6. Release cadence is irregular, typically a few releases per year.
pip install cmweather Common errors
error KeyError: 'viridis' ↓
cause Colormap not registered because cmweather was not imported, or colormap name is incorrect.
fix
Add 'import cmweather' at the top of your script. Use 'plt.get_cmap("cmweather.viridis")'.
error ValueError: Colormap 'cmweather.viridis' is not of known type ↓
cause Matplotlib version too old (<2.0) or cmweather not properly installed.
fix
Upgrade matplotlib: 'pip install matplotlib --upgrade'. Reinstall cmweather: 'pip install cmweather --upgrade'.
error ImportError: cannot import name 'Colormap' from 'cmweather' ↓
cause Trying to import a class that doesn't exist.
fix
Use 'from cmweather import cm' instead.
Warnings
gotcha Colormap names must be prefixed with 'cmweather.' when used in matplotlib (e.g., 'cmweather.viridis'). Omitting the prefix will fall back to matplotlib's default. ↓
fix Use plt.cm.cmweather.viridis or specify cmap='cmweather.viridis'.
deprecated The old direct access via cmweather.colormaps (e.g., cmweather.colormaps['viridis']) is deprecated and may be removed. ↓
fix Use from cmweather import cm; cm.viridis or cmap='cmweather.viridis'.
breaking In v0.2.0, the colormap registration mechanism changed from automatic on import to requiring an explicit import. Code that only did 'import cmweather' before may not register colormaps. ↓
fix Ensure 'import cmweather' is called before plotting. If issues, use 'from cmweather import cm'.
Imports
- cmweather
import cmweather - cmweather.cm wrong
from cmweather import Colormapcorrectfrom cmweather import cm
Quickstart
import matplotlib.pyplot as plt
import numpy as np
import cmweather
# Generate sample data
x = np.linspace(0, 10, 100)
y = np.linspace(0, 10, 100)
X, Y = np.meshgrid(x, y)
Z = np.sin(X) * np.cos(Y)
# Use a CVD-friendly colormap
plt.contourf(X, Y, Z, cmap='cmweather.viridis')
plt.colorbar()
plt.show()