Skip to content

Shared lon/lat labels for rectangular map projections #79

Open

Description

@mickaellalande

I was trying to use shared labels, but I didn't succeed to make it work for longitude and latitude. At least if we write it as for other regular 2D data with x, y, as in the documentation example: https://proplot.readthedocs.io/en/latest/customizing.html#Shared-and-spanning-labels.

Here is an example (data: season_clim_diff.zip):

import xarray as xr
import proplot as plot

season_clim_diff = xr.open_dataarray('season_clim_diff.nc')

f, axs = plot.subplots(
    proj='cyl', proj_kw={'lon_0':180}, ncols=2, nrows=2, axwidth=3, share=3
)

seasons = ['DJF', 'MAM', 'JJA', 'SON']

for i, ax in enumerate(axs):
    m = ax.contourf(
        season_clim_diff.sel(season=seasons[i]), cmap='ColdHot', norm='midpoint'
    )
    ax.format(title=season_clim_diff.sel(season=seasons[i]).season.values)
    
f.colorbar(m, label="Snow Area Fraction [%]")
axs.format(
    geogridlinewidth=0.5, geogridcolor='gray8', geogridalpha=0.5, 
    labels=True, lonlines=60, latlines=30, 
    coast=True, ocean=True, oceancolor='gray4',
    suptitle="Annual snow cover bias (IPSL versus Rutgers)", 
    abc=True, abcstyle='a.'
)

proplot_subplots_share

Thus, with the share=3 option I would expect that the longitudes labels of the first line and the latitudes labels of the last column won't appear.

Activity

  1. lukelbd commented on Dec 4, 2019

    @lukelbd
    Collaborator

    Shared labels are not currently supported for map projections but this is on my to-do list!

    Just like Cartesian axes, I can implement share=3 as the default behavior for Plate Carrée, Mercator, and Miller rectangular projections. For other projections, since the edges are curved, share=0 should probably be the default, but no reason not to allow it.

    One limitation of the "shared labels" feature is it currently only works for labels on the left and bottom. In the PR that addresses this issue, I'll also try to make them work for labels on the right and top. Will also see if I can implement sharing for groups of "twin" axes.

  2. changed the title [-]Shared labels doesn't work with longitude and latitude[/-] [+]Shared lon/lat labels for rectangular map projections[/+] on Jan 7, 2020
  3. added this to the Version 0.10 milestone on Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions