Skip to content

Shared lon/lat labels for rectangular map projections #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mickaellalande opened this issue Dec 4, 2019 · 1 comment
Open

Shared lon/lat labels for rectangular map projections #79

mickaellalande opened this issue Dec 4, 2019 · 1 comment
Labels
Milestone

Comments

@mickaellalande
Copy link
Contributor

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.

@lukelbd lukelbd added the feature label Dec 4, 2019
@lukelbd
Copy link
Collaborator

lukelbd commented Dec 4, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants