【发布时间】:2020-10-11 23:27:24
【问题描述】:
我有一个名为 da 的 xarray DataArray 对象:
<xarray.DataArray 'sm_pct' (month: 12, latitude: 681, longitude: 841)>
array([[[0, 0, ..., 0, 0],
[0, 0, ..., 0, 0],
...,
[0, 0, ..., 0, 0],
[0, 0, ..., 0, 0]],
[[0, 0, ..., 0, 0],
[0, 0, ..., 0, 0],
...,
[0, 0, ..., 0, 0],
[0, 0, ..., 0, 0]],
...,
[[0, 0, ..., 0, 0],
[0, 0, ..., 0, 0],
...,
[0, 0, ..., 0, 0],
[0, 0, ..., 0, 0]],
[[0, 0, ..., 0, 0],
[0, 0, ..., 0, 0],
...,
[0, 0, ..., 0, 0],
[0, 0, ..., 0, 0]]])
Coordinates:
* latitude (latitude) float64 -10.0 -10.05 -10.1 ... -43.9 -43.95 -44.0
* longitude (longitude) float64 112.0 112.0 112.1 112.2 ... 153.9 153.9 154.0
* month (month) int64 1 2 3 4 5 6 7 8 9 10 11 12
我想在 xarray DataArray.plot() 函数中使用 matplotlib LogLocator 和 cartopy 作为底图。
cmap=plt.cm.RdBu_r
central_lon, central_lat = 145, -37
p = da.plot(transform=ccrs.PlateCarree(), levels=20, cmap=cmap, col_wrap=3, aspect=2, size=4, x='longitude', y='latitude', col='month', subplot_kws={'projection': ccrs.Orthographic(central_lon, central_lat)})
原生 matplotlib ax.contourf() 函数具有 locator=ticker.LogLocator() 作为属性。
如何让locator=ticker.LogLocator() 使用 xarray DataArray.plot() 包装函数?
【问题讨论】:
标签: python matplotlib python-xarray cartopy