如何防止Cartopy自动旋转刻度标签?

时间:2020-06-23 17:23:49

标签: python matplotlib cartopy

我正在使用Python 3.8.2,Matplotlib 3.2.1和Cartopy 0.18.0。

当我在Cartopy中创建地图时,有时即使我不要求它也会旋转刻度线标签。这似乎发生了 iff 纬度刻度与水平轴完全对齐的情况。例如:

# Imports
import matplotlib.pyplot as plt
import cartopy.crs as ccrs

# Set up plot
lats = (-0.01, 50.01)
lons = (-0.01, 50.01)
meridians = range(0, 51, 10)
parallels = range(0, 51, 10)
proj = ccrs.PlateCarree()
ax = plt.subplot(111, projection=proj)

# Lat/lon labels
gl = ax.gridlines(draw_labels=True, linewidth=0)
ax.set_xticks(meridians)
ax.set_yticks(parallels)
ax.set_xticklabels([])
ax.set_yticklabels([])

# Set domain
ax.set_extent(tuple(lons + lats), crs=proj)

# Show
plt.show()

这将产生下面的图。如您所见,某些纬度刻度标签已旋转。如何防止这种行为?

Cartopy plot with some ticklabels rotated

0 个答案:

没有答案