Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

error plotting points that wrap around longitudinal map boundaries in plot() method of Basemap

Abierto
#214 7 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
matplotlib, python

Línea de trabajo

Reproduzca el fallo con el script de Python proporcionado y, después, inspeccione mpl_toolkits/basemap/init.py en el plot wrapper y el método shiftdata alrededor de la línea indicada. La corrección estará terminada cuando los puntos sin ordenar [-30, 10, -20] se dibujen sin el error de array ambiguo y se preserve su orden.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Hi

Using Python 2.7.8 and Basemap 1.0.7 there seems to be a problem plotting points that wrap around longitudinal map boundaries in plot() method of Basemap if the points wrap back and forth. The problem can be avoided by sorting the points by longitude prior plotting (but this does of course not work if plotting a segment based on the points since sorting will screw up the order of the points along the segment)

The following code illustrates the problem by plotting the same three points sorted in different ways (first plot works)

#! /usr/bin/env python

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

bm = Basemap(llcrnrlon=0,llcrnrlat=-80,urcrnrlon=360,urcrnrlat=80,projection='mill')
fig=plt.figure(figsize=(8,4.5))   

# figure with three points work
bm.plot([-30,-20,10], [10,10,10], "ro", latlon=True)
plt.show()

# figure with less than three points fail
bm.plot([-30,10,-20], [10,10,10], "ro", latlon=True)
plt.show()

and the error running the above code (after closing the first successful plot window) is

:~/SNSN/ALERT/seedlink> python TryBasemap.py 
Traceback (most recent call last):
  File "TryBasemap.py", line 16, in <module>
    bm.plot([-30,10,-20], [10,10,10], latlon=True)
  File "[...]/python2.7/site-packages/mpl_toolkits/basemap/__init__.py", line 536, in with_transform
    x = self.shiftdata(x)
  File "[...]/python2.7/site-packages/mpl_toolkits/basemap/__init__.py", line 4777, in shiftdata
    if itemindex:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

regP

Lenguaje dominante
Python
Estrellas
818
Forks
395
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de matplotlib/basemap

Todos los issues de matplotlib/basemap

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.