matplotlib / matplotlib/basemap

pcolormesh plot is blank; pcolor plot works

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

还没有人认领这个 Issue。

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

描述

I am experiencing strange behavior using mpl_toolkits.basemap.Basemap.
My understanding is that pcolormesh is faster than pcolor, and thus
preferable. Here is a minimal example (below) where I get a different
plot from pcolormesh than from pcolor.

On two systems (mac os x 10.9.5; Ubuntu 11.04 (GNU/Linux 2.6.32.28
x86_64); basemap 1.0.7 on the mac and 1.0.8 on the Ubuntu machine; both
using matplotlib 1.4.2) I get the expected grid of random colors from
pcolor, but a monochrome plot from pcolormesh.

Is this expected? Are there circumstances in which I should be using
pcolor instead of pcolormesh? Is this a bug in matplotlib or in
basemap?

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

def setup_map(ax):

    m = Basemap(width=8.0e6,
                height=6.5e6,
                projection='aeqd',
                lat_0=54,
                lon_0=-105,
                resolution='l',
                area_thresh=1000, 
                rsphere=6371007.181000,
                fix_aspect=True,
                ax=ax)
    m.drawcoastlines()
    m.drawcountries()
    m.drawstates()
    return(m)

# create pseudo-data with longitudes and latitudes
lon, lat = np.meshgrid(np.arange(-180, 180), 
                       np.arange(90, -90, -1))
data = np.random.rand(*lon.shape) * 100

# two-panel figure
fig, ax = plt.subplots(nrows=1, ncols=2)

# plot pseudodata in left panel using pcolormesh
m0 = setup_map(ax[0])
cm = m0.pcolormesh(lon, lat, data, latlon=True, 
              vmin=0.0, vmax=100.0, cmap=plt.cm.get_cmap("Blues"))
plt.colorbar(cm, ax=ax[0])
ax[0].set_title('pcolormesh')

# plot pseudodata in left panel using pcolor
m1 = setup_map(ax[1])
cm = m1.pcolor(lon, lat, data, latlon=True, 
          vmin=0.0, vmax=100.0, cmap=plt.cm.get_cmap("Blues"))
plt.colorbar(cm, ax=ax[1])
ax[1].set_title('pcolor')

plt.show()

贡献指南

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

从这里开始

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

调研方向

从提供的最小 Python 示例开始,使用报告中的投影和数据比较 Basemap.pcolormesh(..., latlon=True) 与 Basemap.pcolor(..., latlon=True)。确定空白或单色结果是否符合预期,以及所需的更改应归属于 Basemap 还是 matplotlib;完成的标准是解释清楚该行为,并确定一个可复现的修复方案或明确的上游诊断。

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

评估

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

把新 issue 发到你的邮箱

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