import cartopy.crs as ccrs
from cnmaps import get_adm_maps, draw_maps
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
box = [102, 111, 27, 33]
fig=plt.figure(num=1,figsize=(8,6)) ###????.fig
axlevel1 = [0.1, 0.1, 0.65, 0.8]
#maps.province_country_map(box=box,axlevel=axlevel1, xstep=xstep, ystep=ystep, labelon='on')
draw_maps(get_adm_maps(level='國(guó)'),color='gray', linewidth=0.3)
draw_maps(get_adm_maps(level='省'),linewidth=0.3,color='gray')
#draw_maps(city,linewidth=2,color='k')
#draw_maps(get_adm_maps(province='四川省'), color='k', linewidth=0.8)
draw_maps(get_adm_maps(city='成都市'), color='k', linewidth=1.)
draw_maps(get_adm_maps(city='重慶市'), color='k', linewidth=1.)
draw_maps(get_adm_maps(province='四川省',level='市'), color='gray', linewidth=0.1)
plt.axis(box)
ax = plt.gca()
#axis setting
xstep=2
ystep=2
ax.set_xticks(np.arange(box[0], box[1] + xstep, xstep), )
ax.set_yticks(np.arange(20, 40 + ystep, ystep), )
ax.set_xlim(box[0], box[1])
ax.set_ylim(box[2], box[3])
lon_formatter = LongitudeFormatter(zero_direction_label=False)
lat_formatter = LatitudeFormatter()
ax.xaxis.set_major_formatter(lon_formatter)
ax.yaxis.set_major_formatter(lat_formatter)
ax.tick_params(labelsize=22)
fig = plt.figure(figsize=(10,10))
ax = fig.add_subplot(111, projection=ccrs.PlateCarree())
province = get_adm_maps(province='四川省', record='first', only_polygon=True)
province2 = get_adm_maps(city='重慶市', record='first', only_polygon=True)
city = get_adm_maps(city='成都市', record='first', only_polygon=True)
ax.add_geometries(province, crs=ccrs.PlateCarree(), edgecolor='grey', facecolor='grey')
ax.add_geometries(city, crs=ccrs.PlateCarree(), edgecolor='r', facecolor='r')
#draw_maps(get_adm_maps(province='四川省', level='市'), color='k', linewidth=0.8)
ax.set_extent(province.get_extent(buffer=0.5))
plt.show()