【发布时间】:2020-11-06 03:07:34
【问题描述】:
注意:移至 matplotlib quiver key label getting cut 的较小示例
尝试研究如何将箭袋钥匙保留在图中,因为它目前正在被切断。我正在使用 cartopy 并希望将箭袋钥匙放在地图之外。这是它目前的样子。我已经突出显示了箭袋键出现的位置,但东边的文字会自动被切断。下面给出的代码取自docs。
import matplotlib.pyplot as plt
import numpy as np
import cartopy.crs as ccrs
def sample_data(shape=(20, 30)):
crs = ccrs.NorthPolarStereo()
scale = 1e7
x = np.linspace(-scale, scale, shape[1])
y = np.linspace(-scale, scale, shape[0])
x2d, y2d = np.meshgrid(x, y)
u = 10 * np.cos(2 * x2d / scale + 3 * y2d / scale)
v = 20 * np.cos(6 * x2d / scale)
return x, y, u, v, crs
x, y, u, v, vector_crs = sample_data(shape=(50, 50))
fig, ax = plt.subplots(1, 1, figsize=(13, 8))
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines('50m')
ax.set_extent([-45, 55, 20, 80], ccrs.PlateCarree())
q = ax.quiver(x, y, u, v, transform=vector_crs, regrid_shape=20)
qk = plt.quiverkey(q, 1, 0.9, 30,
'velocity (30 m s$^{-1}$)', labelpos='E', transform=ccrs.PlateCarree())
plt.show()
【问题讨论】:
标签: python matplotlib cartopy