import numpy as np
import matplotlib.pyplot as plt
import matplotlib.path as mpath
import matplotlib.ticker as mticker
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import seaborn as sns
sns.set(style='whitegrid')
font = {'family' : 'Times New Roman',
'color' : 'black',
'weight' : 'normal',
'size' : 25,
}
fig1 = plt.figure(figsize=(18,14))
######################################################################整体投影图
leftlon, rightlon, lowerlat, upperlat = (-180,180,-60,-90)
img_extent = [leftlon, rightlon, lowerlat, upperlat]
f1_ax1 = fig1.add_subplot(1, 1, 1, projection=ccrs.SouthPolarStereo())
# f1_ax1 = fig1.add_axes([0.1, 0.1, 0.9, 0.9],projection = ccrs.SouthPolarStereo())
gl=f1_ax1.gridlines(crs=ccrs.PlateCarree(), draw_labels=True,
linewidth=1, color='gray', alpha=0.5, linestyle='--')
gl.ylocator = mticker.FixedLocator([-60,-70, -80])
f1_ax1.set_extent(img_extent, ccrs.PlateCarree())
#通过圆柱投影的范围限制地图范围,这样设置地图参数较为方便
f1_ax1.add_feature(cfeature.COASTLINE.with_scale('50m'))
######以下为网格线的参数######
theta = np.linspace(0, 2*np.pi, 100)
center, radius = [0.5, 0.5], 0.5
verts = np.vstack([np.sin(theta), np.cos(theta)]).T
test=verts * radius + center
a=np.array([[0.5,0.5]])
b=test[33:67]
test1=np.concatenate((a,b,a),axis=0)
circle = mpath.Path(test1)
# ##############################
# 大致思路知道了,先画一个圆的极地投影然后去扇形去截行了
f1_ax1.set_boundary(circle, transform=f1_ax1.transAxes)
plt.savefig('test.jpg', dpi=100)
plt.show()
python画极地局部图
最新推荐文章于 2023-11-13 22:52:23 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)