我绘制了一些由特定坐标和值定义的数据
我已经用散点图绘制了它,现在我想在图像的顶部绘制它,以反映数据点的位置。
我尝试使用matplotlib.image
和导入img
来显示图像。不幸的是,我所在位置的图像与数据不完全匹配(我相信是由于拉伸)
当我编辑extent
时,Python要么编辑掉一些图像,而不是移动数据。我希望能够移动图像/裁剪图像以适应数据,或者使用某种包加载到地图中(因为我有坐标)。这需要显示丹麦的本地流
x
和y
是我们的坐标(lat,lon),而z
是每个坐标的值
plt.figure(figsize=(20,10))
plt.scatter(x,y, cmap = 'gist_heat' ,s=100,c=z)
plt.colorbar()
plt.ylim(np.min(y),np.max(y))
plt.xlim(np.min(x),np.max(x))
img = plt.imread("grindsted4_sattelit.png")
ext = [np.min(x),np.max(x), np.min(y), np.max(y)]
plt.imshow(img, zorder=0, extent=ext)
aspect=img.shape[0]/float(img.shape[1])*((ext[1]-ext[0])/(ext[3]-ext[2]))
plt.gca().set_aspect(aspect)
plt.show()
绘图是彩色点,黑白点是我在Google Earth中的坐标。
谢谢大家!
目前没有回答
相关问题 更多 >
编程相关推荐