【发布时间】:2017-05-24 10:44:31
【问题描述】:
我正在尝试使用 histogram2d 绘制 2D 等高线密度图,i2d 将直方图输出转换为等高线图并使用 contourf 绘制我的数据,但我不欣赏结果,因为它给了我一张带有巨大矩形的地图中间。 这是我正在使用的代码enter image description here
db = 1
lon_bins = np.linspace(min(lons)-db, max(lons)+db, (max(lons)-min(lons))*100)
lat_bins = np.linspace(min(lats)-db, max(lats)+db, (max(lats)-min(lats))*100)
h, xedges, yedges = (np.histogram2d(lats, lons,[lat_bins, lon_bins])
yi, xi = m(*np.meshgrid(lon_bins, lat_bins))
g = np.zeros(xi.shape)
g[:-1,:-1] = h
g[-1] = g[0] # copy the top row to the bottom
g[:,-1] = g[:,0] # copy the left column to the right
print g.shape,yi.shape,xi.shape
cs = m.contourf(yi, xi, g, cmap='Dark2')
cbar = plt.colorbar(cs, orientation='horizontal')
cbar.set_label('la densite des impacts foudre',size=18)
plt.gcf().set_size_inches(15,15)
plt.show()
这是我得到的结果
所以我的要求是如何进行更好的绘图,我不想在中间有那个矩形,我希望我的结果更加平滑...有什么想法吗?
【问题讨论】:
标签: python-2.7 matplotlib-basemap contourf