Skip to content

cmocean:balance#

The balance colormap is diverging with dark blue to off-white to dark red representing negative to zero to positive values; this could be used to represent sea surface elevation, with deviations in the surface elevations as shades of color away from neutral off-white. In this case, shades of red have been chosen to represent sea surface elevation above the reference value (often mean sea level) to connect with warmer water typically being associated with an increase in the free surface, such as with the Loop Current in the Gulf of Mexico. An example of this colormap is from a numerical simulation of the Texas and Louisiana shelf. This colormap is based on RdBu, but was recreated from scratch using the viscm tool.

collection category license authors source
cmocean Diverging MIT Kristen M. Thyng https://github.com/matplotlib/cmocean
from cmap import Colormap

cm = Colormap("cmocean:balance")  # case insensitive
import matplotlib.pyplot as plt
from cmap import Colormap

plt.imshow(data, cmap=Colormap("cmocean:balance").to_mpl())
import plotly.express as px
from cmap import Colormap

px.imshow(data, color_continuous_scale=Colormap("cmocean:balance").to_plotly())
import napari
from cmap import Colormap

napari.imshow(data, colormap=Colormap("cmocean:balance").to_napari())
napari.run()
background: #181C43;
background: linear-gradient(90deg, #181C43 0%, #20285C 3.22581%, #263278 6.45161%, #293D95 9.67742%, #234AB3 12.9032%, #0D5CBE 16.129%, #126DBC 19.3548%, #277CBA 22.5806%, #3D8BBA 25.8065%, #5399BA 29.0323%, #6CA5BC 32.2581%, #86B2C1 35.4839%, #A0BEC8 38.7097%, #B9CAD0 41.9355%, #D0D7DB 45.1613%, #E7E6E6 48.3871%, #EDE4E2 51.6129%, #E6D0CA 54.8387%, #DFBDB2 58.0645%, #D9AA9A 61.2903%, #D49783 64.5161%, #CE856C 67.7419%, #C87255 70.9677%, #C25E41 74.1935%, #BA4A2F 77.4194%, #B13425 80.6452%, #A42025 83.871%, #921128 87.0968%, #7D0E29 90.3226%, #670F24 93.5484%, #510D1C 96.7742%, #3C0912 100%);
import altair as alt
from cmap import Colormap

# df: a DataFrame with columns x, y and value
alt.Chart(df).mark_rect().encode(
    x="x:O",
    y="y:O",
    color=alt.Color(
        "value:Q", scale=alt.Scale(range=Colormap("cmocean:balance").to_altair())
    ),
)
from bokeh.plotting import figure, show
from cmap import Colormap

p = figure()
p.image(
    image=[data], x=0, y=0, dw=1, dh=1,
    color_mapper=Colormap("cmocean:balance").to_bokeh(),
)
show(p)
from vispy import app, scene
from cmap import Colormap

canvas = scene.SceneCanvas(show=True)
view = canvas.central_widget.add_view()
scene.visuals.Image(data, cmap=Colormap("cmocean:balance").to_vispy(), parent=view.scene)
view.camera = scene.PanZoomCamera(aspect=1)
view.camera.set_range()
app.run()
import pygfx as gfx
from cmap import Colormap

image = gfx.Image(
    gfx.Geometry(grid=gfx.Texture(data, dim=2)),
    gfx.ImageBasicMaterial(
        clim=(data.min(), data.max()), map=Colormap("cmocean:balance").to_pygfx()
    ),
)
gfx.show(image)
import pyqtgraph as pg
from cmap import Colormap

view = pg.image(data)
view.setColorMap(Colormap("cmocean:balance").to_pyqtgraph())
pg.exec()
import ee
from cmap import Colormap

ee.Initialize(project="my-project")  # your Google Cloud project
elevation = ee.Image("CGIAR/SRTM90_V4")
image = elevation.visualize(
    min=0, max=3000, palette=Colormap("cmocean:balance").to_gee()
)

See also usage with external libraries.

cmocean:balancecmocean:balance colormap
cmocean:balancecmocean:balance colormap

Perceptual lightness#

Lightness (J′) measured in CAM02 Uniform Color Space (CAM02-UCS)

RGB components#

Hue & saturation#