Skip to content

Label lat lon gridlines parallel to intersection angle at plot boundary #1560

@friedrichknuth

Description

@friedrichknuth

Description

Enhancement to orient lat lon gridline labels parallel to the gridlines as they intersect the plot boundary. Something like the labels seen here:

plot

[source]

Code

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

rotated_crs = ccrs.RotatedPole(pole_longitude=120.0, pole_latitude=70.0)

ax = plt.axes(projection=rotated_crs)
ax.set_extent((-6, 3, 48, 58), crs=ccrs.PlateCarree())
ax.coastlines(resolution='50m')

gl = ax.gridlines(draw_labels=True,x_inline=False, y_inline=False)
plt.show()

Cartopy version
0.18.0

Result

here

Notice the inconsistent orientation of gridline labels, which can get somewhat messy. It is possible to disable the automated orientation feature with gl.rotate_labels = False, however, I can't seem to find a method to align the label angle so that the text is parallel to the gridline as it intersects the plot boundary, as seen in the plot under the description.

Additional Information

I think the logic for this might be here

def _segment_angle_to_text_specs(self, angle, lonlat):

This issue was briefly discussed here ##1089 (comment), but unsure if it has been addressed further.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions