【发布时间】:2017-11-16 17:31:54
【问题描述】:
我正在尝试使用 cartopy、matplotlib 和 imshow 绘制等距(以纬度/经度为单位)数据的方形网格。数据跨越了日期,我在让地图正常工作时遇到了问题。
这是我的问题的一个例子:
import numpy as np
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
lat = np.arange(6000)*0.02 + (-59.99)
lon = np.arange(6000)*0.02 + (85.01)
dat = np.reshape(np.arange(6000*6000),[6000,6000])
tran = ccrs.PlateCarree()
proj = tran
plt.figure(figsize=(8,8))
ax = plt.axes(projection=proj)
print([lon[0],lon[-1],lat[0],lat[-1]])
ax.imshow(dat, extent=[lon[0],lon[-1],lat[0],lat[-1]],transform=tran,interpolation='nearest')
ax.coastlines(resolution='50m', color='black', linewidth=2)
ax.gridlines(crs=proj,draw_labels=True)
plt.show()
tran = ccrs.PlateCarree(central_longitude=180)
proj = tran
plt.figure(figsize=(8,8))
ax = plt.axes(projection=proj)
print([lon[0]-180,lon[-1]-180,lat[0],lat[-1]])
ax.imshow(dat, extent=[lon[0]-180,lon[-1]-180,lat[0],lat[-1]],transform=tran,interpolation='nearest')
ax.coastlines(resolution='50m', color='black', linewidth=2)
ax.gridlines(crs=tran,draw_labels=True)
plt.show()
我想我尝试过重新投影(其中 tran != proj),但它似乎要么挂起,要么花费的时间太长。
我基本上想要底部图像,但带有正确的标签。我将有更多的地理定位数据来覆盖,所以我想正确地做到这一点,而不是现在看起来像一个黑客。
【问题讨论】:
-
没有cartopy,但你不能用
ax.set_xticklabels把标签改成你想要的任何东西吗? -
对我的回答有什么意见/问题吗?
标签: python matplotlib cartopy