It appears that drawmapscale
doesn't support Basemap
instances with projection='cyl'
(and possibly others; I have only checked projection='cyl'
and projection='moll'
):
In [7]: m = Basemap(projection='cyl',resolution='c',area_thresh=10,llcrnrlon=-180,\
urcrnrlon=180, llcrnrlat=-90,urcrnrlat=90)
In [8]: m.etopo()
Out[8]: <matplotlib.image.AxesImage at 0x10a899e90>
In [10]: m.drawmapscale(50, -75, 0, 0, 400)
This results in the following error:
ValueError: cannot draw map scale for projection='cyl'
But drawmapscale
does appear to work for other projections. Using Mollweide, for example:
In [11]: m = Basemap(projection='moll', lon_0=0)
In [12]: m.etopo()
Out[12]: <matplotlib.image.AxesImage at 0x10c299450>
In [13]: m.drawmapscale(50, -75, 0, 0, 400)
Out[13]:
[<matplotlib.lines.Line2D at 0x11d2e41d0>,
<matplotlib.lines.Line2D at 0x109cd4d90>,
<matplotlib.lines.Line2D at 0x11d2e4750>,
<matplotlib.text.Text at 0x11d2e4d90>,
<matplotlib.text.Text at 0x11d2e5610>]
Unfortunately the Basemap API doesn't seem to mention anything about it not working for all projections. But here seems to be a potential workaround.