Картопия с проекцией Робинсона?Python

Программы на Python
Anonymous
Картопия с проекцией Робинсона?

Сообщение Anonymous »

Я новичок в Python и пытаюсь запустить следующий код.

Код: Выделить всё

from matplotlib.ticker import AutoMinorLocator

fig, (ax) = plt.subplots(nrows=1, ncols=1, figsize=fig_size_single_golden, constrained_layout=True,
subplot_kw=dict(projection=ccrs.Robinson(central_longitude=-118.0))
)

cb = dia_depth_smooth.plot(
ax=ax,
robust=True,
x='geolon_t', y='geolat_t',
cmap=cm.cm.deep, vmin = 0, vmax = 2500, #norm=mcolors.SymLogNorm(linthresh=100, linscale=0.25,vmin=0.0, vmax=3000, base=10),
transform=ccrs.PlateCarree(),
shading='nearest',
cbar_kwargs={"shrink": 0.8, "aspect": 40, "pad": 0.04, "orientation":"horizontal", "label":"Diapause Depth (metres)"});

cb.colorbar.ax.yaxis.set_minor_locator(AutoMinorLocator())
#cb.colorbar.ax.invert_yaxis()

ax.coastlines(linewidth=0.5)
ax.add_feature(cartopy.feature.LAND, zorder=1, facecolor='gray', edgecolor='black', linewidth=0.5)
ax.set_title('')

#fig.tight_layout(pad=0)
plt.savefig('Figure1b.png', format='png', dpi=600, bbox_inches="tight", pad_inches=0)
Ошибка

Код: Выделить всё

ValueError: For X (361) and Y (201) with flat shading, A should have shape (200, 360, 3) or (200, 360, 4) or (200, 360) or (72000,), not (263,)
Это сработало бы, только если бы я использовал следующую ортогональную проекцию вместо проекции Робинсона

Код: Выделить всё

ccrs.Orthographic
Chatgpt сказал, что это из-за сетки. Может ли кто-нибудь помочь мне с более подробными решениями?
Большое спасибо!

Вернуться в «Python»