Python绘图,填色图叠加青藏高原边界,需要青藏高原shape文件

from scipy.io import loadmat
import numpy as np
address = 'G:/work2022/python/SCF_month_1966-2018_observation/'
matfn = address + '01.mat'#读取mat文件名
data = loadmat(matfn)
w1 = data['scf']

matfn = address + '02.mat'#读取mat文件名
data = loadmat(matfn)
w2 = data['scf']

matfn = address + '12.mat'#读取mat文件名
data = loadmat(matfn)
w3 = data['scf']
w = np.zeros((360,1440,26,3))
w[0:360,0:1440,0:26,0]=w1[0:360,0:1440,14:40]
w[0:360,0:1440,0:26,1]=w2[0:360,0:1440,14:40]
w[0:360,0:1440,0:26,2]=w3[0:360,0:1440,13:39]
wmean=np.nanmean(w,axis=3)
wm=np.nanmean(wmean,axis=2)

## 绘图
lon=np.arange(0.125-180,180,0.25)
lat=np.arange(90-0.125,0,-0.25)
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
from cartopy.io.shapereader import Reader
Alberts_China = ccrs.AlbersEqualArea(central_longitude=105,
                            standard_parallels=(25.0, 47.0)) 
# 1
fig = plt.figure()
proj = ccrs.PlateCarree(central_longitude=0)
extents = [65, 105, 25, 40]
ax = plt.subplot(111, projection=proj)
ax.set_extent(extents, crs=proj)
ax.set_xticks(np.arange(65, 106, 10), crs=proj)
ax.set_yticks(np.arange(25, 45, 5), crs=proj)
ax.xaxis.set_major_formatter(LongitudeFormatter())
ax.yaxis.set_major_formatter(LatitudeFormatter())
reader    = Reader('G:/work2022/python/SCF_month_1966-2018_observation/TPBoundary_new(2021).shp')
ax.add_geometries(reader.geometries(),
                   crs=ccrs.PlateCarree(), # 坐标系需要对应,不然可能会出现坐标不对应的情况哦
                   edgecolor='r',
                   linewidths=2,facecolor='none') 
c2 = ax.contourf(lon,lat,wm, levels=np.arange(0,1.1,0.1),
            cmap=plt.cm.jet,zorder=0)
cbar = fig.colorbar(c2, orientation='horizontal', 
                    fraction=0.5, pad=0.12, aspect=20, shrink=0.65)
cbar.set_ticks([0,0.2,0.4,0.6,0.8,1.0])
cbar.set_label('SCF') 
ax.set_title('(a) Winter',loc='left')
cbar.set_label('SCF',fontsize=15) 
ax.set_title('(a)Winter',loc='left',fontsize=15)
# 设置刻度字体大小
plt.xticks(fontsize=15)
plt.yticks(fontsize=15)
cbar.ax.tick_params(labelsize=15) 
plt.show();
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

碧海蓝天_BLUE2016

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值