pydata / pydata/xarray

Improve plot aspect handling when using cartopy

Open
#619 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement topic-plotting
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

This applies to single plots and FacetGrids.

The current plotting behavior when using a projection that changes the plot aspect is as follows:

from xray.tutorial import load_dataset

ds = load_dataset('air_temperature')

ax = plt.subplot(projection=ccrs.LambertConformal())
ds.air.isel(time=0).plot(transform=ccrs.PlateCarree())
ax.coastlines()
ax.gridlines()

single

fg = ds.air.isel(time=slice(0, 9)).plot(col='time', col_wrap=3, transform=ccrs.PlateCarree(),
                                   subplot_kws=dict(projection=ccrs.LambertConformal()))
for ax in fg.axes.flat:
    ax.coastlines()
    ax.gridlines()

facet

There are two problems here, I think both are related to the aspect of the subplot:

  1. In the single case, the subplot aspect is correct but the colorbar is not scaled appropriately
  2. In the FacetGrid case, the subplot aspects are not correct but the colorbar is.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce both examples: the single plot with a LambertConformal projection and the FacetGrid using subplot_kws. Start from the plotting and FacetGrid aspect-handling entry points, then compare subplot sizing with colorbar scaling. Done means both single and faceted plots have correct projected aspects and appropriately scaled colorbars.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.