Skip to content

Fix gridline labels ignoring side visibility on curved projections#2649

Open
guillermodotn wants to merge 1 commit intoSciTools:mainfrom
guillermodotn:main
Open

Fix gridline labels ignoring side visibility on curved projections#2649
guillermodotn wants to merge 1 commit intoSciTools:mainfrom
guillermodotn:main

Conversation

@guillermodotn
Copy link

Rationale

On non-rectangular projections (e.g. Robinson), gridline labels on the curved boundary get classified as "geo" instead of a named side, bypassing right_labels=False (or equivalent).

For example, 60°N and 60°S still appear on the right even when gl.right_labels = False.

Closes #2607

After fix sample:
image

Implications

  • Single condition expanded in _draw_gridliner: when a label's loc is "geo", also check the angle-derived side attribute. Uses is False to avoid changing default behavior for users who haven't explicitly disabled a side.
  • No additional tests added.

@CLAassistant
Copy link

CLAassistant commented Mar 24, 2026

CLA assistant check
All committers have signed the CLA.

@adrifoster
Copy link

Is there a way to fix this without having to update the version once this comes in? I'm trying to plot something and I am having trouble getting the 60N and 60S to disappear:

    fig, axes = plt.subplots(nrows, ncols, figsize=(width, height),
                            subplot_kw=dict(projection=ccrs.Robinson()),
                            layout="compressed")
                            
    for i, da in enumerate(das):

        map_function(axes[i], da, titles[i], cmap=cmap, vmin=-0.5, vmax=len(cols)-0.5)
        
        gls = axes[i].gridlines(draw_labels=True, dms=True, x_inline=False,
                          y_inline=False)
        gls.top_labels = False
        gls.right_labels = False
        
        if i%ncols > 0:
            gls.left_labels = False
        if i < (len(axes) - ncols):
            gls.bottom_labels = False
    
        gls.ylocator = FixedLocator([-60, -30, 0, 30, 60])
        gls.xlabel_style = {'size': 10}
        gls.ylabel_style = {'size': 10}
        axes[i].set_extent([-180, 180, -60, 89], crs=ccrs.PlateCarree())
        
        ```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot disable the right latitude labels of the gridlines

3 participants