contour and contourf produce conflicing results for certain projections
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- matplotlib, numpy, python
調査の方向性
まず、data5.bin を使って再現された Python の例を実行し、ステレオ投影で contourf と contour を比較します。投影後の x/y グリッドが各プロット呼び出しにどのように渡されているかを確認し、次に issue に記載されている円筒図法、Lambert Conformal、Albers の結果を比較します。入力データを変更せずに、北米地域を含めて contourf が期待されるデータと一致すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Originally posted here because I wasn't convinced it was a bug (I'm new to matplotlib)... but I'm increasingly convinced it is a bug, so here we are.
I'm plotting some NCEP temperature anomaly data using the stereographic projection. When I plot the data with filled contours, contourf, I see the first picture below. Note the red (positive values) over most of North America. When I change contourf to contour, making no other changes, I see the second picture below. Note the streak of blue (negative values) over central North America.


The contour result with the blue is what is actually in the data, and therefore what I expect to see. The contourf result is not what I expect. Is this a bug, or am I using these tools improperly? (Update: The first plot above should look like the below plot, which was produced using the cylindrical projection:)

The python code is reproduced below... you can obtain the data as a small binary file here if you want to try it yourself.
Some more notes... (1) shifting the longitude range to -180 to 180 using addcyclic and shiftgrid does not help. (2) the Lambert Conformal ('lcc') projection produces results that are less wrong, but still not correct, when using contourf. (3) the Alberts Equal Area ('aea') projection centered on North America looks correct, however when I use the North Pole-centric version ('nplaea') I only see correct results for certain values of lon_0. I am happy to provide an example if this turns out to be a different issue.
import numpy as np
import matplotlib.pyplot as plt
# read data
f = open('data5.bin', 'r')
lat = np.fromfile(f,dtype=np.float32,count=73)
lon = np.fromfile(f,dtype=np.float32,count=144)
data = np.reshape(np.fromfile(f,dtype=np.float32,count=-1),(73,144))
f.close()
# plot
m = Basemap(width=10000000,height=6000000,
resolution='l',projection='stere',\
lat_ts=50,lat_0=50,lon_0=253)
m.drawcoastlines()
lon2d, lat2d = np.meshgrid(lon,lat)
x, y = m(lon2d,lat2d)
mymap = plt.contourf(x,y,data,levels=np.arange(17)-8,cmap=plt.cm.bwr)
plt.colorbar(mymap,orientation='vertical',shrink=0.75)
plt.show()
- 主要言語
- Python
- スター
- 817
- フォーク
- 395
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
matplotlib/basemap のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
matplotlib/basemap#368 ·
-
Python 3.14 wheels オープン
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
matplotlib/basemap#652 · コメント 2 件 · リアクション 5 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
matplotlib/basemap#649 · リアクション 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
matplotlib/basemap#646 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 48/100
matplotlib/basemap#645 · コメント 2 件 ·
matplotlib/basemap の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
anthropics/skills#1811 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
speaches-ai/speaches#678 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
datalayer/mcp-compose#42 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
conda-forge/spacy-feedstock#177 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
UKGovernmentBEIS/inspect_evals#2523 ·