【发布时间】:2021-01-18 12:45:52
【问题描述】:
您好,尝试导入底图时出现此错误
ImportError: cannot import name 'dedent' from 'matplotlib.cbook'
我已经尝试了很多故障排除,但无法解决。 我正在使用 Windows 和 Anaconda。
在thisreddit 中,它使用“make”命令,但这对我在 Windows 上不起作用。从我的谷歌搜索中,我看到它的原因是一个 linux 命令。
我也尝试从不同位置下载底图,但并没有真正帮助我。
我还了解到底图已贬值,现在人们使用 cartopy,但我在导入 cartopy 时也遇到了问题。
我想做的只是在美国地图上叠加数据,这给我带来了很多问题。如果有人可以帮助我,我将不胜感激。
对于那些好奇我是否可以通过其他方式实现的人,这里是我正在尝试实现的底图代码:
df_city_salary = df[["Location","average_salary"]]
scale=1
map = ccrs(llcrnrlon=-119,llcrnrlat=22,urcrnrlon=-64,urcrnrlat=49,
projection='lcc',lat_1=32,lat_2=45,lon_0=-95)
# load the shapefile, use the name 'states'
map.readshapefile('st99_d00', name='states', drawbounds=True)
# Get the location of each city and plot it
geolocator = Nominatim()
for (city,count) in df_city_salary:
loc = geolocator.geocode(city)
x, y = map(loc.longitude, loc.latitude)
map.plot(x,y,marker='o',color='Red',markersize=int(math.sqrt(count))*scale)
plt.show()
TL;DR:安装底图的最简单方法。 ELI5 为白痴安装底图
【问题讨论】:
标签: python pandas matplotlib matplotlib-basemap