contour and contourf produce conflicing results for certain projections
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- matplotlib, numpy, python
- Área
- data-visualization
Línea de trabajo
Comienza ejecutando el ejemplo de Python reproducido con data5.bin y comparando contourf y contour bajo la proyección estereográfica. Revisa cómo se pasan las cuadrículas x/y proyectadas a cada llamada de trazado y, después, compara los resultados cilíndricos, Lambert Conformal y Albers descritos en el issue. Se considera terminado cuando contourf coincide con los datos esperados, incluida la región de Norteamérica, sin cambiar los datos de entrada.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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()
- Lenguaje dominante
- Python
- Estrellas
- 817
- Forks
- 395
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de matplotlib/basemap
-
small bug in drawmapscale Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
matplotlib/basemap#368 ·
-
Python 3.14 wheels Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
matplotlib/basemap#652 · 2 comentarios · 5 reacciones ·
-
Could you allow packaging 26.0 ? Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 45/100
matplotlib/basemap#649 · 2 reacciones ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
matplotlib/basemap#646 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 48/100
matplotlib/basemap#645 · 2 comentarios ·
Todos los issues de matplotlib/basemap
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
anthropics/skills#1811 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
speaches-ai/speaches#678 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
datalayer/mcp-compose#42 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
conda-forge/spacy-feedstock#177 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
UKGovernmentBEIS/inspect_evals#2523 ·