Skip to content

Incorrect discrete 'curl' colormap #116

Open
@bbuzz31

Description

@bbuzz31

Looks like something is off when you specify a discrete normalization with the curl colormap.
The code below will produce 4 plots; the first 3 are as expected but the last one demonstrates the issue. Colors are no longer centered around 0 (white).

import matplotlib.pyplot as plt
import cmocean
import numpy as np

data = np.random.normal(loc=0, size=(10, 10))
norm = mpl.colors.TwoSlopeNorm(0, -2, 2)

plt.imshow(data, cmap='cmo.balance', norm=norm)
plt.colorbar()
plt.title('TwoSlopeNorm, Balance (Correct)')

plt.figure()
plt.imshow(data, cmap='cmo.curl', norm=norm)
plt.colorbar()
plt.title('TwoSlopeNorm, Curl (Correct)')

bounds = np.linspace(-2, 2, 21)
norm = mpl.colors.BoundaryNorm(bounds, 256)

plt.figure()
plt.imshow(data, cmap='cmo.balance', norm=norm)
plt.colorbar()
plt.title('BoundaryNorm, Balance (CORRECT)')

plt.figure()
plt.imshow(data, cmap='cmo.curl', norm=norm)
plt.colorbar()
plt.title('BoundaryNorm, Curl (INCORRECT)');

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions