问题
I'm plotting a map using Stamen tiles inside a matplotlib figure like so:
tiler=Stamen('terrain-background')
mercator=tiler.crs
ax3=fig.add_subplot(gs01[1,0], projection=ccrs.PlateCarree())
ax3.add_image(tiler,14)
I then attempt to rotate the gridline tick labels like so:
gl3=ax3.gridlines(crs=ccrs.PlateCarree(), draw_labels=True, linewidth=1., color='gray', alpha=0.75, linestyle='--')
gl3.left_labels=False
gl3.top_labels=False
gl3.xlabel_style={'size':10., 'color':'gray', 'weight':'bold'}
gl3.ylabel_style={'size':10., 'color':'gray', 'weight':'bold'}
gl3.rotate_labels=45
Unfortunately, nothing is rotated when I open the PNG file that I save in the script. Is there another way that I can rotate gridline tick labels?
回答1:
Right, so I found an answer on the cartopy issue tracker.
You can change the rotation angle by setting
gl3.xlabel_style = {'rotation': 45}
gl3.ylabel_style = {'rotation': 45}
来源:https://stackoverflow.com/questions/62904409/how-can-i-rotate-gridline-labels-on-a-cartopy-map