matplotlib / matplotlib/basemap
CEA projection: plotting all the data works, plotting part of the data fails.
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 817
- Forks
- 395
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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()
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.
Línea de trabajo
Reproduce los dos ejemplos con la configuración de Python 2.7, matplotlib 1.2.1 y Basemap 1.0.6; después, inspecciona mpl_toolkits/basemap/init.py alrededor de los puntos de entrada m1.plot transform y shiftdata que se muestran en el traceback. Se considera terminado cuando el trazado del subconjunto de dos puntos se realiza correctamente y el ejemplo relacionado de múltiples puntos ya no genera los errores de indexación o de valor booleano indicados.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100