cmocean provides a collection of aesthetically pleasing and perceptually uniform colormaps specifically designed for oceanographic data visualization. It integrates seamlessly with Matplotlib. The current version is 4.0.3, and it receives active maintenance with frequent patch releases and less frequent major version updates.
pip install cmoceanVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import a cmocean colormap (`cm.haline`) and use it with Matplotlib's `imshow` function to visualize a 2D array of data.
Always import `cmocean.cm` (e.g., `import cmocean.cm as cm`) and then reference colormaps as `cm.colormap_name`.
Ensure `matplotlib` is installed (`pip install matplotlib`) and that your environment has a suitable backend for displaying plots (e.g., an interactive backend for GUI, or a non-interactive backend for saving figures).
Upgrade `cmocean` to version `4.0.2` or newer (`pip install --upgrade cmocean`) to resolve issues with the `tools` module.
Colormaps are stored in `cmocean.cm`. Use `cmocean.cm.haline` (or `cm.haline` if aliased `import cmocean.cm as cm`).
Ensure `matplotlib` is installed (`pip install matplotlib`). If running a script without an interactive display, use `plt.savefig('my_plot.png')` instead of `plt.show()` or configure a non-interactive backend like `matplotlib.use('Agg')`.Upgrade `cmocean` to version `4.0.2` or later: `pip install --upgrade cmocean`.