matplotlib / matplotlib/basemap

CEA projection: plotting all the data works, plotting part of the data fails.

Aperta
#126 9 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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

Using the following setup, Python 2.7/matplotlib 1.2.1/basemap 1.0.6

from mpl_toolkits import basemap

m1 = basemap.Basemap(projection='cea', lon_0=0)
lon = [-135, -45, 45, 135]
lat = [45, 45, 45, 45]

If I then run the following command, the line plots as expected:

m1.plot(lon, lat, latlon=True)

But plotting just the first two points alone gives a failure:

m1.plot(lon[:2], lat[:2], latlon=True)

Here's the result:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-273-c6f75eb64ab8> in <module>()
      8 lat = [45, 45, 45, 45]
      9 #m1.plot(lon, lat, latlon=True)
---> 10 m1.plot(lon[:2], lat[:2], latlon=True)

/Users/jakevdp/anaconda/python.app/Contents/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.pyc in with_transform(self, x, y, *args, **kwargs)
    525             if self.projection in _cylproj or self.projection in _pseudocyl:
    526                 if x.ndim == 1:
--> 527                     x = self.shiftdata(x)
    528                 elif x.ndim == 0:
    529                     if x > 180:

/Users/jakevdp/anaconda/python.app/Contents/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.pyc in shiftdata(self, lonsin, datain, lon_0)
   4700             londiff = np.abs(lonsin[0:-1]-lonsin[1:])
   4701             londiff_sort = np.sort(londiff)
-> 4702             thresh = 360.-londiff_sort[-2]
   4703             itemindex = len(lonsin)-np.where(londiff>=thresh)[0]
   4704             if itemindex:

IndexError: index -2 is out of bounds for axis 0 with size 1

Edit: here's an error from a similar call, but I believe it's unrelated to the first:

lat = [-45, 45, 45, 45, 45, 0]
lon = [135, -135, -45, 45, 135, -90]
m1.plot(lon, lat, latlon=True)

error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-295-d815d338a0b6> in <module>()
     11 lon = [135, -135, -45, 45, 135, -90]
     12 
---> 13 m1.plot(lon, lat, latlon=True)
     14 

/Users/jakevdp/anaconda/python.app/Contents/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.pyc in with_transform(self, x, y, *args, **kwargs)
    525             if self.projection in _cylproj or self.projection in _pseudocyl:
    526                 if x.ndim == 1:
--> 527                     x = self.shiftdata(x)
    528                 elif x.ndim == 0:
    529                     if x > 180:

/Users/jakevdp/anaconda/python.app/Contents/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.pyc in shiftdata(self, lonsin, datain, lon_0)
   4702             thresh = 360.-londiff_sort[-2]
   4703             itemindex = len(lonsin)-np.where(londiff>=thresh)[0]
-> 4704             if itemindex:
   4705                 # check to see if cyclic (wraparound) point included
   4706                 # if so, remove it.

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci i due esempi con la configurazione Python 2.7, matplotlib 1.2.1 e Basemap 1.0.6, quindi esamina mpl_toolkits/basemap/init.py in corrispondenza degli entry point m1.plot transform e shiftdata mostrati nel traceback. Il lavoro è completato quando il plotting del sottoinsieme di due punti riesce e l’esempio correlato con più punti non genera più gli errori di indicizzazione o di valore booleano segnalati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
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
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.