Improve plot aspect handling when using cartopy
Open
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()

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()

There are two problems here, I think both are related to the aspect of the subplot:
- In the single case, the subplot aspect is correct but the colorbar is not scaled appropriately
- In the FacetGrid case, the subplot aspects are not correct but the colorbar is.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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