我想创建一个函数,当您在地图上单击鼠标点时,返回x,y值
lonGrid, latGrid = np.meshgrid(self.lonBathymetry[lon_inds[0 [0:-1:stepLon]], self.latBathymetry[lat_inds[0][0:-1:stepLat]])
bathymetry = self.gb.variables['elevation'][ lat_inds[0][0:-1:stepLat] , lon_inds[0][0:-1:stepLon]]
self.m = Basemap(ax=self.axes, projection='cyl',llcrnrlat=lat_min,urcrnrlat=lat_max,\
llcrnrlon=lon_min,urcrnrlon=lon_max,resolution=res)
xi, yi =self.m(lonGrid, latGrid)
def mousePressEvent(self, event):
lonGrid= self.canvas.lonGrid
latGrid= self.canvas.latGrid
x = event.latGrid()
y = event.lonGrid()
答案 0 :(得分:0)
如果这是matplotlib画布,则坐标应在event.x
和event.y
中可用。