Basemap error: module object is not callable

痞子三分冷 提交于 2021-01-28 08:00:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!