matplotlib / matplotlib/basemap

Problems with Basemap.scatter

Open
#191 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
817
Forks
395
PR merge metrics
No merged PRs in 30d

Description

Hi,

I have stumbled over a bug in scatter plot. With latlon=True, it crashes with zero, one or two points.

Example code:

import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

bmap = Basemap(projection='merc',
               llcrnrlon=9, urcrnrlon=13,
               llcrnrlat=63, urcrnrlat=65,
               resolution='c')

lon = [10.0, 12.0]
lat = [64.0, 65.0]

bmap.scatter(lon, lat, latlon=True)

plt.show()

This crashes with the following Traceback:

Traceback (most recent call last):
  File "a.py", line 12, in <module>
    bmap.scatter(lon, lat, latlon=True)
  File "/opt/anaconda/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.py", line 536, in with_transform
    x = self.shiftdata(x)
  File "/opt/anaconda/lib/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

I am using python 2.7.10, matplotlib 1.4.3, basemap 1.0.7 on a 64-bit Linux machine

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Basemap.scatter example with latlon=True and inspect the shiftdata entry point in mpl_toolkits/basemap/init.py, where the traceback fails for small inputs. Done means scatter handles zero, one, and two points without raising IndexError.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.