Python底图热图

问题描述

我正在尝试复制在此页面上完成的方法https://makersportal.com/blog/2018/7/20/geographic-mapping-from-a-csv-file-using-python-and-basemap在“映射有趣的数据”下以使颜色栏与我的数据相关联。

现在我只得到一张南美的普通地图,这就是我想要的背景,但是没有数据。

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

m = Basemap(projection='mill',llcrnrlat = -30,#bottom
            llcrnrlon = -120,#left 
            urcrnrlat = 20,#top
            urcrnrlon = -50,#right 
            resolution='c')

m.drawcoastlines()
m.drawcountries()

# format colors for elevation range
sst_min = np.min(df5.Daasgardsst)
sst_max = np.max(df5.Daasgardsst)
cmap = plt.get_cmap('gist_earth')
normalize = matplotlib.colors.normalize(vmin=sst_min,vmax=sst_max)

# plot sst with different colors
for i in range(0,len(df5.Daasgardsst)):
    x,y = m(lon,lat)
    color_interp = np.interp(df5,[sst_min,sst_max],[0,30])
    plt.plot(x,y,marker='o',markersize=6,color=cmap(int(color_interp)))

# format the colorbar 
cax,_ = matplotlib.colorbar.make_axes(ax)
cbar = matplotlib.colorbar.ColorbarBase(cax,cmap=cmap,norm=normalize,label='Elevation')


plt.title('Title')

plt.show()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)