import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from matplotlib.colors import Normalize
import numpy as np
import geopandas as gpd
#====================================================================
y_pred = np.random.random((389, 28, 14))
world = gpd.read_file("ne_110m_land/ne_110m_land.shp")
min_lat = 19.25
max_lat = -5.75
min_lon = 18.5
max_lon = 31.5
lat = np.tile(np.arange(max_lat, min_lat-0.5, -0.5).reshape(-1, 1), (1, int(max_lon - min_lon+1)))
lon = np.tile(np.arange(min_lon, max_lon+1, 1).reshape(1, -1), (int((max_lat - min_lat)*2)+1, 1))
#====================================================================
''' Plot map '''
norm = Normalize(vmin=0, vmax=max(y_pred.ravel()))
fig_map, ax_map = plt.subplots(1,1,figsize=(6,6), dpi=100, tight_layout=True)
fig_map.set_size_inches(6, 6)
map = ax_map.scatter(x=lon, y=lat, c=y_pred[date_idx], s=4, cmap='bwr', norm=norm)
world.plot(ax=ax_map, facecolor='none', edgecolor='black', linewidth=.5, alpha=1)
divider = make_axes_locatable(ax_map)
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(map, cax=cax)
ax_map.set_xlim(-20, 60)
ax_map.set_ylim(-20, 20)
ax_map.set_aspect('equal')
plt.show()
fig_map.savefig('test.png', bbox_inches='tight', pad_inches=0)
Подробнее здесь: https://stackoverflow.com/questions/787 ... raphic-map