matplotlib / matplotlib/cmocean
Incorrect discrete 'curl' colormap
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 269
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
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)');
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the issue's four-plot reproduction with matplotlib, cmocean, numpy, TwoSlopeNorm, and BoundaryNorm. Compare the cmo.balance and cmo.curl results under BoundaryNorm, then inspect the curl colormap setup and relevant normalization behavior; done means discrete curl colors are centered around 0 like the continuous example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100