How can I rotate gridline labels on a cartopy map?

六眼飞鱼酱① 提交于 2021-01-28 19:54:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!