matplotlib / matplotlib/basemap

Strange lines appear when using pcolormesh with nonzero alpha value

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

还没有人认领这个 Issue。

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

描述

When plotting data using pcolormesh on a basemap projection (or a cartopy projection) I notice strange lines appear when I set the alpha value to less than 1.

Example code:

```
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt

plt.clf()

dpp =1 # degrees per pixel
lons = np.arange(-180,180+dpp,dpp)
lats = -1*np.arange(-90,90+dpp,dpp)

m = Basemap(projection='robin',lon_0=0)
data = np.random.random((np.size(lats), np.size(lons)))
lons, lats = np.meshgrid(lons, lats)
x, y = m(lons, lats)

im = m.pcolormesh(x, y, x, latlon=False, cmap='RdBu')
#im = m.pcolormesh(lons, lats, data, latlon=True, cmap='RdBu')

m.colorbar(im)
plt.show()
```

The output shows strange lines appearing:

![test1](https://user-images.githubusercontent.com/9418465/71375327-d5733300-258b-11ea-9b5c-51b8b8646658.png)

If I instead set alpha=1 the lines disappear and the behavior is as expected:

![test2](https://user-images.githubusercontent.com/9418465/71375338-e2902200-258b-11ea-805c-a5e4a1469848.png)

Any ideas on what the issue is or how to get pcolormesh to work with a nonzero alpha value?

贡献指南

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

从这里开始

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

调研方向

首先运行提供的、使用 Robinson 投影的 Basemap.pcolormesh 示例,比较 alpha 小于 1 与 alpha=1 的情况。跟踪 pcolormesh 调用进入 matplotlib 渲染路径,并找出为什么投影后的单元格在透明度合成期间会产生可见线条。使用非不透明 alpha 时,复现出的图中没有非预期线条,即表示完成。

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

评估

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

把新 issue 发到你的邮箱

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