matplotlib / matplotlib/basemap
Shiftdata breaks pcolormesh wrapping
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 817
- Fork
- 395
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
I have a data grid which spans the whole globe from -180 -> 180. pcolormesh can plot this OK if I have lon_0=0 in which case Basemap doesn't have to do any wrapping

However if I do this for lon_0=180 (where Basemap has to shift some data), I get the following incorrect plot:

The code I have used for this is (using 1.0.7):
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
x = np.arange(-180, 190, 10)
y = np.array([40, 50, 60])
data = np.arange(72).reshape((2, 36))
xv, yv = np.meshgrid(x, y)
# Add an empty row and column of data so that the data is the same shape as X,Y
wider_data = np.ma.zeros(xv.shape)
for index, v in np.ndenumerate(data):
wider_data[index] = data[index]
for lon in (0, 180):
map = Basemap(lon_0=lon)
map.drawparallels(np.arange(-90, 90, 20), labels=[1, 1, 0, 1])
map.drawmeridians(np.arange(-180, 180, 30), labels=[1, 1, 0, 1])
map.pcolormesh(xv, yv, wider_data, latlon=True)
map.drawcoastlines()
plt.show()
I suspect that this problem is related to https://github.com/matplotlib/basemap/issues/182 because to get around that issue, I have had to add an empty row and column to the data. This should still be OK though, since that extra data should just be ignored (from the pcolormesh docs).
However, what actually happens is that the empty row gets moved around because shiftdata doesn't know it should ignore and so the plot is wrong.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo la riproduzione fornita di Basemap 1.0.7 con pcolormesh e confronta i grafici lon_0=0 e lon_0=180. Ispeziona il percorso shiftdata utilizzato da pcolormesh per il wrapping; il lavoro è completato quando la riga e la colonna aggiuntive rimangono ignorate e il grafico traslato corrisponde alla griglia globale prevista.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- matplotlib, numpy, python
- Ambito
- data-visualization
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100