cmocean: Colormaps for Oceanography

4.0.3 · active · verified Fri Apr 17

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.

Common errors

Warnings

Install

Imports

Quickstart

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

view raw JSON →