Skip to content

error plotting less than 2 points using plot() method of Basemap #213

@paitor

Description

@paitor

Hi

Running python 2.7.8 and Basemap 1.0.7 (downloaded and installed today at about 1045 UTC) I fail to plot less than 3 points using the plot() method. I've tested this using the following script:

#! /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([10,15,20], [10,10,10], "ro", latlon=True)
plt.show()

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

And the exception is:

:~> python TryBasemap.py 
Traceback (most recent call last):
  File "TryBasemap.py", line 16, in <module>
    bm.plot([10,15], [10,10], "ro", 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 4775, in shiftdata
    thresh = 360.-londiff_sort[-2]
IndexError: index -2 is out of bounds for axis 0 with size 1

Whilst the first plot is successful, the second fail

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions