- 积分
- 135
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2022-7-15
- 最后登录
- 1970-1-1
|
发表于 2022-8-18 18:08:12
来自手机
|
显示全部楼层
li134 发表于 2022-08-18 16:14
全部代码不太好分享给你,这一部分是画这种图的代码,你可以参考一下
经纬度处理:
lat = np.arange(2.5, 55, 5)
lon=np.arange(72.5,140, 5)
lons0, lats0 = np.meshgrid(lon, lat)
画图:
plt.rcParams['font.family'] = ['Arial']
SHP = r'E:\data\dilixinxi\3.caotopy地图配置及shp文件读取\china_shp'
fig= plt.figure(figsize=(12,8),dpi=300)
proj = ccrs.PlateCarree(central_longitude=105) #设置一个圆柱投影坐标,中心经度115°E
leftlon, rightlon, lowerlat, upperlat = (70,140,0,55)#设置地图边界范围
'''#####################################10min_N###########'''
ax1 = fig.add_axes([0.06, 0.52, 0.28, 0.28],projection = proj)#figure的百分比,从figure 10%的位置开始绘制, 宽高是figure的80%
#left, bottom, width, height = 0.1, 0.1, 0.8, 0.8
#获得绘制的句柄
#ax1 = fig.add_axes([left, bottom, width, height])
#ax1.plot(x, y, ‘r’)
ax1.set_extent([leftlon, rightlon, lowerlat, upperlat], crs=ccrs.PlateCarree())#设置边界
ax1.add_feature(cfeature.COASTLINE.with_scale('50m'),linewidth=0.5)#参数scale为地图分辨率,目前支持10m,50m,110m
#f2_ax1.add_feature(cfeature.LAKES, alpha=0.5)
ax1.set_xticks(np.arange(leftlon,rightlon+10,20), crs=ccrs.PlateCarree())
ax1.set_yticks(np.arange(lowerlat,upperlat+5,10), crs=ccrs.PlateCarree())
lon_formatter = cticker.LongitudeFormatter()
lat_formatter = cticker.LatitudeFormatter()
ax1.xaxis.set_major_formatter(lon_formatter)
ax1.yaxis.set_major_formatter(lat_formatter)
ax1.set_title('(a) ',loc='left',fontsize =12)
#ax1.set_title( 'm' ,loc='right',fontsize =10)
#填充
china = shpreader.Reader('E:\lidan\data\dilixinxi\\bou2_4m\\bou2_4l.dbf').geometries()
ax1.add_geometries(china,ccrs.PlateCarree(),facecolor='None', edgecolor='black',linewidth=0.5,zorder = 1)#facecolor:表面颜色,edgecolorl:边缘色
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
bounds=[0,1000,2000,3000,4000,5000,6000,7000,8000,9000,10000]
norl=colors.BoundaryNorm(boundaries=bounds, ncolors=256,extend='both')
norl_res=colors.BoundaryNorm(boundaries=bounds_res, ncolors=256,extend='both')
c=ax1.pcolormesh(lons0,lats0,np.array(n10).reshape(11,14),transform=ccrs.PlateCarree(),norm=norl,alpha=0.75,cmap='jet')#precip3_16lev
plt.show()
其中n10是我处理后的一维变量
非常感谢,,谢谢,我来看一看 |
|