NaN
NaN

Reputation: 691

How can I rotate gridline labels on a cartopy map?

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?

Upvotes: 1

Views: 2290

Answers (1)

Denis Sergeev
Denis Sergeev

Reputation: 1140

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}

Upvotes: 4

Related Questions