Log-scaled colors (LogNorm)

LogNorm maps color on a log scale, revealing structure across several orders of magnitude that a linear norm flattens.

plot 08 lognorm

Live figure — pick a tool, then zoom, pan, point-pick or annotate. Nothing is active until a tool is selected.

View this figure’s Vega export ↗ — the raw JSON spec, rendered live by a real Vega engine.

View this figure’s Vega-Lite export ↗ — the raw JSON spec(s), rendered live by a real Vega-Lite engine.

import numpy as np
import plotpress

g = np.linspace(-3, 3, 200)
X, Y = np.meshgrid(g, g)
Z = np.exp(-(X ** 2 + Y ** 2)) * 1000 + 1     # spans ~1 .. 1000

fig, axes = plotpress.subplots(1, 2, figsize=(10, 4))
m0 = axes[0].pcolormesh(g, g, Z, cmap="inferno")
axes[0].set_title("linear norm")
fig.colorbar(m0, ax=axes[0])
m1 = axes[1].pcolormesh(g, g, Z, cmap="inferno", norm=plotpress.LogNorm())
axes[1].set_title("LogNorm")
fig.colorbar(m1, ax=axes[1])          # decade ticks, positioned logarithmically
fig.tight_layout()

Total running time of the script: (0 minutes 0.259 seconds)

Gallery generated by Sphinx-Gallery