matplotlib / matplotlib/cmocean

Incorrect discrete 'curl' colormap

未关闭
#116 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
269
派生
54
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用 matplotlib、cmocean、numpy、TwoSlopeNorm 和 BoundaryNorm 运行 issue 中的四图复现。比较在 BoundaryNorm 下 cmo.balance 和 cmo.curl 的结果,然后检查 curl 颜色映射的设置和相关的归一化行为;完成的标准是离散的 curl 颜色像连续示例一样以 0 为中心。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
data-visualization
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。