- 积分
- 5966
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-9-11
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 schliezer 于 2018-2-5 16:54 编辑
地图遮住了阴影,但我明明是先画的地图,另外,有没有办法可以只保留第一列子图的坐标?所有坐标挤在一起很难看。代码和图:- 2# -*- coding: utf-8 -*-
- """
- Created on Thu Jan 25 09:18:00 2018
- """
- import numpy as np
- import matplotlib.pyplot as plt
- from scipy.io import loadmat
- from matplotlib.patches import Polygon
- from scipy.interpolate import griddata
- from mpl_toolkits.basemap import Basemap
- from matplotlib.font_manager import FontProperties
- font=FontProperties(fname=r'c:\windows\fonts\simsun.ttc',size=14)
- lonlat=loadmat('C:\Users\CQQXT\Documents\MATLAB\BP_forecast_onebyone\lonlat.mat')
- AnnualRain_Ratio=loadmat('C:\Users\CQQXT\Documents\MATLAB\BP_forecast_onebyone\AnnualRain_Ratio.mat')
- Rain_Ratio=loadmat('C:\Users\CQQXT\Documents\MATLAB\BP_forecast_onebyone\Rain_Ratio.mat')
- StnName=loadmat('C:\Users\CQQXT\Documents\MATLAB\BP_forecast_onebyone\StnName.mat')
- sample=loadmat('C:\Users\CQQXT\Documents\MATLAB\BP_forecast_onebyone\sample.mat')
- Token=loadmat('C:\Users\CQQXT\Documents\MATLAB\BP_forecast_onebyone\Token.mat')
- New_Rain_Ratio=loadmat('C:\Users\CQQXT\Documents\MATLAB\BP_forecast_onebyone\New_Rain_Ratio.mat')
- grid_lon,grid_lat=np.meshgrid(np.arange(105,110.5,0.1),np.arange(28,32.5,0.1))
- lon_lat=np.transpose(np.array([lonlat['lonlat'][:,0],lonlat['lonlat'][:,1]]))
- fig=plt.figure()
- for i in range(6):
- names=locals()
- names['ax%s'%(i+1)]=fig.add_subplot(2,3,i+1)
- # ax0=fig.add_axes([0.85,0.10,0.04,0.80])
- map=Basemap(projection='cyl',resolution='l',llcrnrlon=105,llcrnrlat=28,urcrnrlon=111,urcrnrlat=33,ax=names['ax%s'%(i+1)])
- shapeinfo=map.readshapefile('F:\\2016\\Youth_Foundation\\CHN_adm_shp\\CHN_adm3','states',drawbounds=False)
- for info, shp in zip(map.states_info,map.states):
- proid=info['NAME_1']
- if proid=='Chongqing':
- poly=Polygon(shp,facecolor='w',edgecolor='k',lw=0.5)
- names['ax%s'%(i+1)].add_patch(poly)
- map.drawparallels(np.arange(28,33,2),color='k',labels=[1,0,0,0])
- map.drawmeridians(np.arange(105,110,2),color='k',labels=[0,0,0,1])
- agency=griddata(lon_lat,AnnualRain_Ratio['AnnualRain_Ratio'][:,i],(grid_lon,grid_lat),method='cubic')
- cf=map.contourf(grid_lon,grid_lat,agency)
- # cb=map.colorbar(cf,'right',size='5%')
- # plt.title(u'降水频率')
复制代码
|
-
|