Skip to content
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

Gallery: show colour bar stealing space from multiple axes #5537

Merged
merged 4 commits into from
Oct 10, 2023

Conversation

rcomer
Copy link
Member

@rcomer rcomer commented Oct 9, 2023

🚀 Pull Request

Description

It was embarrassingly recent that I realised you can get Matplotlib to automatically place a colour bar across multiple axes. Probably because I originally came to the Iris gallery to learn this sort of thing. This PR modifies one example to show such placement rather than manually placing a colour bar axes. Note that we also have the GloSea example showing manual colour bar placement.

I have two versions of this in the two commits. In the first commit, I created Cartopy GeoAxes up front so that I could pass the original array of axes to colorbar. I the second commit, I reverted that and found a different way to get hold of the GeoAxes that Iris auto-creates. I am in two minds which is the right version to keep: I think the first version is Better Object Oriented Code, but the second version better illustrates Iris' capabilities (and gotchas).


Consult Iris pull request check list

@rcomer
Copy link
Member Author

rcomer commented Oct 9, 2023

Needs SciTools/iris-test-data#86

@rcomer rcomer changed the title Gallery: show colour bar stealing from multiple axes Gallery: show colour bar stealing space from multiple axes Oct 9, 2023
@codecov
Copy link

codecov bot commented Oct 9, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (58220d1) 89.41% compared to head (e9bc206) 89.41%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5537   +/-   ##
=======================================
  Coverage   89.41%   89.41%           
=======================================
  Files          89       89           
  Lines       22539    22539           
  Branches     5387     5387           
=======================================
  Hits        20154    20154           
  Misses       1639     1639           
  Partials      746      746           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rcomer
Copy link
Member Author

rcomer commented Oct 9, 2023

I was totally expecting a failure because the reference image needs updating 😕

@trexfeathers
Copy link
Contributor

I was totally expecting a failure because the reference image needs updating 😕

#5539

Copy link
Contributor

@trexfeathers trexfeathers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I'm happy that this works, and it's definitely more elegant / more idiomatic Matplotlib. I prefer the second approach - the one currently in the PR - as it is more typical Iris use with less to explain.

Got one thing I'd be keen for you to change in the What's New.

docs/src/whatsnew/latest.rst Outdated Show resolved Hide resolved
@rcomer
Copy link
Member Author

rcomer commented Oct 10, 2023

I think I also need to update the test data version?

@trexfeathers
Copy link
Contributor

I think I also need to update the test data version?

Yes please, thanks for the reminder

@trexfeathers trexfeathers merged commit 0b569cd into SciTools:main Oct 10, 2023
17 checks passed
@rcomer
Copy link
Member Author

rcomer commented Oct 10, 2023

Thanks @trexfeathers 😀

@rcomer rcomer deleted the gallery-cop-colorbar branch October 10, 2023 15:46
tkknight added a commit to tkknight/iris that referenced this pull request Oct 26, 2023
* upstream/main:
  moved latest warning banner logic to conf.py (SciTools#5508)
  updated layout of top navbar (SciTools#5505)
  Oblique and Rotated Mercator (SciTools#5548)
  [pre-commit.ci] pre-commit autoupdate (SciTools#5549)
  [pre-commit.ci] pre-commit autoupdate (SciTools#5527)
  Bump scitools/workflows from 2023.09.1 to 2023.10.0 (SciTools#5540)
  nep29 drop table schedule numpy>1.21 (SciTools#5525)
  Updated environment lockfiles (SciTools#5545)
  Replaced `NotImplementedError` with `NotImplemented` (SciTools#5544)
  Gallery: show colour bar stealing space from multiple axes (SciTools#5537)
  Updated environment lockfiles (SciTools#5524)
  Set some memory benchmarks to on-demand to reduce noise. (SciTools#5481)
  updating docs and stale comment (SciTools#5522)
  Ensure removal of release candidate from What's New title. (SciTools#5526)
  Updated environment lockfiles (SciTools#5513)
  Docs page on filtering warnings (SciTools#5509)
  Replaced pkg_resources version parser with packager version parser. (SciTools#5511)
  Categorise warnings (SciTools#5498)
  Updated all np.product calls to np.prod (SciTools#5493)
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.

2 participants