Чтобы получить график карты с цветовой шкалой, необходимо указать несколько параметров. Вот рабочий код, который демонстрирует, как установить значения figsize
и colorbar
для получения лучшего графика.
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
#import cartopy.feature as cfeature
import numpy as np
# make up data for plotting
xmin, xmax, ymin, ymax = -55, 15, -4, 4
#extent = [xmin, xmax, ymin, ymax]
width = 4
height = 4
xs = np.linspace(xmin, xmax, width)
ys = np.linspace(ymin, ymax, height)
x2d, y2d = np.meshgrid(xs, ys)
z2d = (x2d+y2d)
fig = plt.figure(figsize=(20,5)) # set figsize (width, height) here
ax = plt.axes(projection=ccrs.PlateCarree())
ct = ax.contourf(x2d, y2d, z2d, 30, cmap='RdBu_r')
ax.coastlines()
gridlines = ax.gridlines(draw_labels=True)
# create a colorbar
cbar = plt.colorbar(ct, fraction=.08, pad=0.04, shrink=0.5, aspect=12)
cbar.set_label('Power Spectrum (m$^2$/# frequencies)', labelpad=15, y=.5, rotation=270)
plt.title('Frequency Summed Power Spectrum (2018-2019)', y=1.2)
plt.show()
Выходной участок:
![enter image description here](https://i.stack.imgur.com/JqeiW.png)