问题
I am trying to learn how to use basemap in python. I used the following site for learning http://www.datadependence.com/2016/06/creating-map-visualisations-in-python/. but when I typed the following
import matplotlib.pyplot as plt
import matplotlib.cm
import basemap
fig,ax=plt.subplots(figsize=(10,20))
m=basemap(resolution='c',projection='merc',lat_0=54.5,lon_0=-4.36,llcrnrlon=-6.,llcrnrlat=49.5,urcrnrlon=2.,urcrnrlat=55.2)
m.drawmapboundary(fill_color='#46bcec')
m.fillcontinents(color='#f2f2f2',lake_color='#46bcec')
m.drawcoastlines()
I get an error as TypeError: 'module' object is not callable
. Why is the reason for this?
回答1:
You misunderstood the example code. You have to write:
from mpl_toolkits.basemap import Basemap
m=Basemap(resolution='c',projection='merc',lat_0=54.5,lon_0=-4.36,llcrnrlon=-6.,llcrnrlat=49.5,urcrnrlon=2.,urcrnrlat=55.2)
Basemap
have to be start from capital letter. It is very important for Python. Python is case sensitivity language.
来源:https://stackoverflow.com/questions/45685170/basemap-error-module-object-is-not-callable