Использование set_extent на Polar Stereo Графические карты, похоже, не работают # предсказуемым образом. Я следую этому примеру с ответом StackOverflow , но ни один поворот не # дает карту. Я установил ax1.set_global()
для отображения данных.
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.examples.waves import sample_data
# read sample data
x, y, z = sample_data(shape=(73, 145))
fig = plt.figure(figsize=(8, 8))
# first plot with default rotation. Global extent, works fine
ax1 = fig.add_subplot(221, projection=ccrs.NorthPolarStereo())
cs1 = ax1.contourf(x, y, z, 50, transform=ccrs.PlateCarree(),
cmap='gist_ncar')
ax1.set_title('Global')
#next plot setting extent to 0,360,40,90, no display
ax2 = fig.add_subplot(222,
projection=ccrs.NorthPolarStereo())
cs2 = ax2.contourf(x, y, z, 50,
transform=ccrs.PlateCarree(),
cmap='gist_ncar')
ax2.set_extent([0,360,40,90],crs=ccrs.PlateCarree())
ax2.coastlines()
ax2.set_title('Centred on 0$^\circ$ (default)')
#Now resetting set_extent to [-180,180,40,90] strangely works!
ax3 = fig.add_subplot(
223, projection=ccrs.NorthPolarStereo())
cs3 = ax3.contourf(x, y, z, 50, transform=ccrs.PlateCarree(),
cmap='gist_ncar')
ax3.set_extent([-180, 180, 40, 90], crs=ccrs.PlateCarree())
ax3.coastlines()
ax3.set_title('Using -180,180 $^\circ$W')
#but now rotating projection yields just a corner of the map
ax4 = fig.add_subplot(
224,projection=ccrs.NorthPolarStereo(central_longitude=-45))
cs4 = ax4.contourf(x, y, z, 50, transform=ccrs.PlateCarree(),
cmap='gist_ncar')
ax4.set_extent([-180, 180, 40, 90], crs=ccrs.PlateCarree())
ax4.coastlines()
ax4.set_title('Rotated on -45 $^\circ$W')
plt.show()
Я ожидал, что set_extent будет работать так, как задокументировано, но, похоже, # странное взаимодействие между вращением и экстентом
выход