python画极地局部图

这段代码使用Cartopy库在Python中创建了一个南极极地投影地图,并设置了网格线和海岸线。它还展示了如何裁剪地图以显示特定的经度和纬度范围,并添加了自定义的圆形边界。最后,保存了生成的地图为'test.jpg'。
摘要由CSDN通过智能技术生成
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()

在这里插入图片描述

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值