我想制作一个聚焦于欧洲的Lambert Conic图。我可以执行以下操作:
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
proj = ccrs.LambertConformal(central_longitude=20.0, central_latitude=45.0, cutoff=30)
fig = plt.figure(figsize=(10,10))
ax = fig.add_subplot(111, projection=proj)
ax.coastlines(resolution='110m')
plt.show()
然而,这太多地延伸到了东方和西方。我想把它缩小到,比如说,在10W到40E之间。如果我添加一行ax.set_extent([-10,40,30,90], crs=ccrs.PlateCarree())
,我会失去上面图中的二次曲线“外观”:
怎样才能适当地减小Cartopy's LambertConformal中的纵向范围,同时仍然保持二次曲线的外观?我可以给出经度边距,让第一个数字在两个子午线之间进行调整,而不是放在这个矩形中吗?我想象两个子午线之间有一个三角形,在纬度较低的地方有一个拱形。
发布于 2021-01-13 03:34:21
这就是你要找的东西吗?
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import matplotlib.path as mpath
ax = plt.axes(projection=ccrs.LambertConformal(central_longitude=20.0, central_latitude=45.0))
ax.gridlines()
ax.coastlines(resolution='110m')
# Lon and Lat Boundaries
xlim = [-10, 40]
ylim = [30, 90]
lower_space = 10 # this needs to be manually increased if the lower arched is cut off by changing lon and lat lims
rect = mpath.Path([[xlim[0], ylim[0]],
[xlim[1], ylim[0]],
[xlim[1], ylim[1]],
[xlim[0], ylim[1]],
[xlim[0], ylim[0]],
]).interpolated(20)
proj_to_data = ccrs.PlateCarree()._as_mpl_transform(ax) - ax.transData
rect_in_target = proj_to_data.transform_path(rect)
ax.set_boundary(rect_in_target)
ax.set_extent([xlim[0], xlim[1], ylim[0] - lower_space, ylim[1]])
改编自this example。
输出:
https://stackoverflow.com/questions/65687535
复制相似问题