如何使用不同的数组绘制多个Cartopy子图图

时间:2019-07-13 16:45:42

标签: python-3.x

我想绘制一系列总共18张的地图(此脚本中只有两张)。每个地图绘制一个不同的数组。此时出现警告标签,指出“先前的轴当前正在重用早期的实例”。

当前仅显示一张地图: enter image description here

感谢您的帮助

NP_array2 = np.loadtxt('C:\\Users\\VeraFranke\\Desktop\\Mappings\\2003AE_450winter.txt')

df_arrays = {'NP_array':NP_array,'NP_array2':NP_array2}

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

lons = np.arange(-180, 180, 1)
lats = np.arange(0, 90, 1)

# create the projections
rotated_pole = ccrs.RotatedPole(pole_latitude=ZEP_lat, pole_longitude=ZEP_long)
North_Stereo = ccrs.NorthPolarStereo(central_longitude=0) #central_longitude=-90)
ortho = ccrs.Orthographic(central_longitude=ZEP_long, central_latitude=ZEP_lat)

#central_longitude=11, central_latitude=79)
geo = ccrs.Geodetic()

fig, axs = plt.subplots(1, 2, figsize=(6, 3))

for my_array,ax in zip(df_arrays,axs):

    ax = plt.axes(projection=ortho)

    # plot north pole for reference (with a projection transform)                                                                                           
    ax.plot([ZEP_long], [ZEP_lat], 'ro', transform=geo)
    ax.set_extent([-180, 180, 45, 90], crs=ccrs.PlateCarree())

    print(df_arrays[my_array])

    psm = ax.pcolormesh(lons, lats, df_arrays[my_array], transform=rotated_pole, vmin=0, vmax=6, cmap='inferno')

    cbar = fig.colorbar(psm, extend='both', ax=ax)

    # add coastlines for reference                                                                                                
    ax.coastlines(resolution='50m')

plt.show() 

0 个答案:

没有答案