Registry / data / cmocean

cmocean

JSON →
library4.0.3pypypi✓ verified 87d ago

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 cmocean
INSTALL
IMPORT
SIG · CMOCEAN
C
cmocean
datapythonv4.0.3
Install
7.7s avg
Import
3090ms
Disk
182MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 3.140s · 178.9MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 7.7s · import 3.040s · 171MB
182MB installed
● package 182MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cm
import cmocean.cm as cm
import cmocean as cm
Colormaps are exposed via the `cm` submodule, not directly from the top-level package.

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.

import matplotlib.pyplot as plt import cmocean.cm as cm import numpy as np # Create some dummy data data = np.random.rand(10, 10) # Plot using a cmocean colormap plt.imshow(data, cmap=cm.haline) plt.colorbar(label='Data Value') plt.title('Data with cmocean.haline Colormap') # To display the plot, uncomment the line below in an interactive environment # plt.show() # Save to a file if not in an interactive environment # plt.savefig('cmocean_example.png') plt.close() # Close plot to prevent display if running as script
Debug
Known issues
gotchacmocean colormaps are typically accessed through the `cmocean.cm` submodule. Attempting to directly access colormaps from the top-level `cmocean` module (e.g., `cmocean.haline`) will result in an `AttributeError`.
fix
Always import `cmocean.cm` (e.g., `import cmocean.cm as cm`) and then reference colormaps as `cm.colormap_name`.
affects: All versions
gotchaWhile `cmocean` provides colormaps, its practical utility relies entirely on `matplotlib` for rendering. If `matplotlib` is not installed or configured correctly, `cmocean` colormaps cannot be displayed or used effectively.
fix
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).
affects: All versions
gotchaIn `cmocean` versions prior to `4.0.2`, a typo in the `cmocean.tools` module could cause issues when trying to retrieve certain colormaps using utility functions like `cmocean.tools.get_cmap()`. Direct access via `cmocean.cm.colormap_name` was unaffected.
fix
Upgrade `cmocean` to version `4.0.2` or newer (`pip install --upgrade cmocean`) to resolve issues with the `tools` module.
affects: <4.0.2
Errors
Common errors & fixes
AttributeError: module 'cmocean' has no attribute 'haline'
Attempting to access a colormap directly from the top-level `cmocean` module instead of its `cm` submodule.
fix
Colormaps are stored in `cmocean.cm`. Use `cmocean.cm.haline` (or `cm.haline` if aliased `import cmocean.cm as cm`).
TypeError: 'NoneType' object is not callable (or similar error when trying to show a plot)
`matplotlib.pyplot` was imported, but a plotting function (like `plt.show()`) was called in an environment without a suitable graphical backend or `matplotlib` is not correctly installed.
fix
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')`.
KeyError: 'cmap_name' (when using cmocean.tools.get_cmap)
In `cmocean` versions prior to `4.0.2`, a typo in the `cmocean.tools` module prevented some colormaps from being correctly identified by the utility functions.
fix
Upgrade `cmocean` to version `4.0.2` or later: `pip install --upgrade cmocean`.
Upgrade
Version history
4.0.3latest on PyPI · released Apr 6, 2024
Audit
Dependencies
matplotlibrequiredEssential for visualizing cmocean colormaps; cmocean provides the colormaps, but Matplotlib renders them.
numpyoptionalOften used in conjunction with Matplotlib for data processing when generating plots, though not a strict dependency of cmocean itself.
Agent activity
26 hits · last 30 days
node
20
OpenAI (training)
1
Resources
cmocean — pip install cmocean · libregistry