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

Corrected plot_anomaly_log_colouring for new Matplotlib linscale rules. #4115

Merged
merged 1 commit into from
May 4, 2021

Conversation

trexfeathers
Copy link
Contributor

🚀 Pull Request

Description

Restores output of the anomaly log colouring gallery to pre #4087 by using a new linscale argument (can't go back to linscale=0 as no longer allowed by Matplotlib).


Consult Iris pull request check list

vmin=-maximum_scale_level,
vmax=maximum_scale_level,
)
# Setting "linthresh=minimum_log_level" makes its non-logarithmic
# data range equal to our 'zero band'.
# Setting "linscale=1" maps the whole zero band to the middle colour value
# Setting "linscale=0.01" maps the whole zero band to the middle colour value
# (i.e., 0.5), which is the neutral point of a "diverging" style colormap.
Copy link
Member

@rcomer rcomer May 4, 2021

Choose a reason for hiding this comment

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

I'll be honest, I'm really struggling to match this comment up with what the mpl docs say about linscale. I'm getting the feeling that either the original comment was wrong, or the behaviour has changed. Or I'm just missing something... 😕

Copy link
Member

Choose a reason for hiding this comment

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

It's the first bit about "linthresh=minimum_log_level" that I'm particularly struggling with, rather than the changed bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The language of these comment lines makes no sense to me either, but I assumed that to be due to the writer's greater knowledge in this area. Seems important to understand and correct before merging.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like @pp-mo was the originator, but a Whole Seven Years Ago!!! #1040

Copy link
Member

Choose a reason for hiding this comment

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

Given how much matplotlib would have moved on in seven years, it's entirely possible that there are better ways of achieving this outcome now anyway. So possibly we should just merge this now for the sake of fixing master, and open a new issue to revisit later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having read in more detail and talked it over with @stephenworsley, I'm reasonably happy with how it's written already.

Copy link
Member

@pp-mo pp-mo Jul 6, 2021

Choose a reason for hiding this comment

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

Just found this.
FWIW there was a perfectly good documentation for this up to Matplotlib v3.3,
https://matplotlib.org/3.3.4/api/_as_gen/matplotlib.colors.SymLogNorm.html

But they seem to have lost it somewhere since ??

update : It's not unique : a lot of the classes have lost their docstring details.
I'm trying to work out how to raise this as an issue.

@trexfeathers
Copy link
Contributor Author

The good news is that this finally gives us a passing py3.8 doc tests (gallery).

Copy link
Member

@jamesp jamesp 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 to me, the only failing tests now are the square root failures 👍

@jamesp jamesp merged commit 055a60b into SciTools:master May 4, 2021
rcomer pushed a commit to rcomer/iris that referenced this pull request May 12, 2021
jamesp added a commit that referenced this pull request May 13, 2021
* mpl 3.4.1 updates (#4087)

* replace most recent hashes (#4112)

* Corrected plot_anomaly_log_colouring for new Matplotlib linscale rules. (#4115)

* Cartopy 0.19 updates (#4128)

* Use assertArrayAllClose for sqrt test (#4118)

* using AllClose for sqrt test

* Omitting the checksum from test cml

* use ArrayAllClose (rebase reset it?)

* Iris py38 (#3976)

* support for py38

* update CI and noxfile

* enforce alphabetical xml element attribute order

* full tests for py38 + fix docs-tests

* add whatsnew entry

* update doc-strings + review actions

* Alternate xml handling routine (#29)

* all xml tests pass for nox tests-3.8

* restored docstrings

* move sort_xml_attrs

* make sort_xml_attrs a classmethod

* update sort_xml_attr doc-string

Co-authored-by: Bill Little <bill.james.little@gmail.com>

* add jamesp to whatsnew + minor tweak

Co-authored-by: James Penn <james@jamespenn.co.uk>

* reinstate black and nox links

* Linkcheck update (#4104)

* Updated links

* Added login remark

* Removed extra space

* change to kick cirrus

* kick cirrus

* test verbose on cirrus

* Removed test settings.

Co-authored-by: Bill Little <bill.james.little@gmail.com>
Co-authored-by: Martin Yeo <40734014+trexfeathers@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: James Penn <james.penn@metoffice.gov.uk>
Co-authored-by: James Penn <james@jamespenn.co.uk>
Co-authored-by: tkknight <2108488+tkknight@users.noreply.github.com>
tkknight added a commit to tkknight/iris that referenced this pull request May 17, 2021
* master: (49 commits)
  Update CI environment lockfiles + Cartopy 0.19 changes (SciTools#4125)
  separate arg types from descriptions (SciTools#4100)
  Use assertArrayAllClose for sqrt test (SciTools#4118)
  Removed branch suffix (SciTools#4117)
  Corrected plot_anomaly_log_colouring for new Matplotlib linscale rules. (SciTools#4115)
  replace most recent hashes (SciTools#4112)
  Linkcheck update (SciTools#4104)
  CI lockfiles (SciTools#4108)
  Fix bug in gallery_tests runner (SciTools#4111)
  add logo to conda and pypi badges (SciTools#4088)
  pre-commit-ci update (SciTools#4092)
  Fix cirrus ci and mpl (SciTools#4087)
  Update readme docs stable (SciTools#4089)
  linux kernel version fix for conda 4.10+ (SciTools#4084)
  update docs pypi instructions (SciTools#4077)
  update flake8 pre-commit (SciTools#4067)
  Add GitHub discussions badge (SciTools#4070)
  conda requirements add pip (SciTools#4062)
  add pre-commit.ci badge and doc support (SciTools#4061)
  cirrus-ci credits for non-master (SciTools#4060)
  ...
tkknight added a commit to tkknight/iris that referenced this pull request May 26, 2021
* master: (87 commits)
  Contourf Antialias Fix (SciTools#4150)
  minor tidy of cirrus and nox (SciTools#4152)
  update bug and feature templates (SciTools#4147)
  Update CI environment lockfiles + Cartopy 0.19 changes (SciTools#4125)
  separate arg types from descriptions (SciTools#4100)
  Use assertArrayAllClose for sqrt test (SciTools#4118)
  Removed branch suffix (SciTools#4117)
  Corrected plot_anomaly_log_colouring for new Matplotlib linscale rules. (SciTools#4115)
  replace most recent hashes (SciTools#4112)
  Linkcheck update (SciTools#4104)
  CI lockfiles (SciTools#4108)
  Fix bug in gallery_tests runner (SciTools#4111)
  add logo to conda and pypi badges (SciTools#4088)
  pre-commit-ci update (SciTools#4092)
  Fix cirrus ci and mpl (SciTools#4087)
  Update readme docs stable (SciTools#4089)
  linux kernel version fix for conda 4.10+ (SciTools#4084)
  update docs pypi instructions (SciTools#4077)
  update flake8 pre-commit (SciTools#4067)
  Add GitHub discussions badge (SciTools#4070)
  ...
pp-mo added a commit to pp-mo/iris that referenced this pull request Jul 6, 2021
pp-mo pushed a commit to pp-mo/iris that referenced this pull request Jul 7, 2021
abooton pushed a commit that referenced this pull request Aug 10, 2021
* Add release highlights and pin rc version (#3898)

* Add release highlights and pin rc version

* review actions

* reorder release highlights (#3899)

Tweak release highlights

* Add whatsnew announcement (#3900)

* Fix spelling (#3903)

* Fix unit label handling (#3902)

* Add failing test of plotting

* Implement fix to pass test

* Update idiff to ignore irrelevant hyphens in path

* Update imagerepo (following docs)

* Update after review by @trexfeathers

* Add whatsnew entries

* Move whatsnew entries into correct file

* Release Docs Improvements (#3895)

* Minor phrasing change in 'Release candidate'.

* Before release deprecations.

* Whatsnew highlights section.

* Relax setup.py setup requirements (#3909)

* Updated CF saver version in User Guide and docstring (#3925)

* Updated CF saver version in User Guide and docstring

* Remove references to CF version of the loader in docstrings

* Added whatsnew

* Pin cftime<1.3.0

* Migrate to cirrus-ci (#3928)

* migrate from travis-ci to cirrus-ci

* added whatsnew entries

* ignore url for doc link check (#3929)

* whatsnew for coord default units (#3924)

* Cube._summary_coord_extra: efficiency and bugfix (#3922)

* Add Documentation Title Case Capitalization (#3940)

* Use Title Case Capitalisation for Documentation

* add whatsnew enter

* CI requirements drop pip packages (#3939)

* requirements pip to conda

* use pip install over develop

* default PY_VER to python versions

* update links (#3942)

* update links

* added s to http

* Add support for 1-d weights in collapse. (#3943)

* Remove warning for convert_units on lazy data (#3951)

* drop stickler references in docs (#3953)

* drop stickler references in docs

* remove sticker from common links

* update docs for travis-ci to cirrus-ci (#3954)

* update docs for travis-ci to cirrus-ci

* add 'travis-ci' reference locally to whatsnew

* update whatsnew comment

* docs for nox (#3955)

* docs for nox

* add titles, notices and additional detail

* review actions

* Resolve test coverage (#3947)

* test coverage for __init__ and __call__

* test coverage for metadata resolve and coverage

* partial test coverage for metadata mapping

* python 3.6 workaround for deepcopy of mock.sentinel

* test coverage for Resolve._free_mapping

* test coverage for Resolve convenience methods

* add test stub for Resolve._metadata_mapping

* fix Test__tgt_cube_position

* test coverage for shape

* test coverage for _as_compatible_cubes

* test coverage for Resolve._metadata_mapping

* test coverage for Resolve._prepare_common_dim_payload

* test coverage for Resolve._prepare_common_aux_payload

* test coverage for Resolve._prepare_points_and_bounds

* test coverage for Resolve._create_prepared_item

* test coverage for Resolve._prepare_local_payload_dim

* test coverage for Resolve._prepare_local_payload_aux

* test coverage for Resolve._prepare_local_payload_scalar + docs URL skip

* test coverage for Resolve._prepare_local_payload

* test coverage for Resolve._metadata_prepare

* added docs URL linkcheck skip

* test coverage for Resolve._prepare_factory_payload

* test coverage for Resolve._get_prepared_item

* review actions

* test coverage for Resolve.cube

* pin v3.0.0 version and whatnew date (#3956)

* update github ci checks image (#3957)

* Promote unknown units to dimensionless in aux factories (#3965)

* promote unknown to dimensionless units in aux factories

* patch aux factories to promote unknown to dimensionless units for formula terms

* add whatnew PR for entry

* Release branch prepare for v3.0.2 (#4044)

* update intersphinx mapping and matplotlib urls (#4003)

* update intersphinx mapping and matplotlib urls

* use matplotlib intersphinx where possible

* review actions

* review actions

* cirrus-ci compute credits (#4007)

* cirrus-ci conditional tasks (#4019)

* cirrus-ci conditional tasks

* use bc for bash arithmetic

* revert back to sed

* use expr

* reword

* minor documentation changes

* review actions

* prepare v3.0.2 release

* Fix test_incompatible_dimensions test (#3977)

* test_incompatible_dimensions used a ragged array for the test, which has been deprecated in numpy, and now fails if dtype is anything other than object.  This test appears to be checking that the addition of a [2x4] masked array to a [2x3] masked cube should raise a ValueError. This commit fixes the creation of `data3` object to be a [2x4] non-ragged array.

* Added entry to what's new

* Added name to core developer list :)

* Update latest.rst

Fixed space in PR macro call

* update whatsnew v3.0.2

Co-authored-by: James Penn <james@jamespenn.co.uk>

* um_stash_source attribute improved handling (#4035)

* Modified pyke rule

* Tests added

* Black and whatsnew

* Include PR number

* Remove latest.rst

* Add what's new

* Support for py38 and Cartopy 0.19 (#4130)

* mpl 3.4.1 updates (#4087)

* replace most recent hashes (#4112)

* Corrected plot_anomaly_log_colouring for new Matplotlib linscale rules. (#4115)

* Cartopy 0.19 updates (#4128)

* Use assertArrayAllClose for sqrt test (#4118)

* using AllClose for sqrt test

* Omitting the checksum from test cml

* use ArrayAllClose (rebase reset it?)

* Iris py38 (#3976)

* support for py38

* update CI and noxfile

* enforce alphabetical xml element attribute order

* full tests for py38 + fix docs-tests

* add whatsnew entry

* update doc-strings + review actions

* Alternate xml handling routine (#29)

* all xml tests pass for nox tests-3.8

* restored docstrings

* move sort_xml_attrs

* make sort_xml_attrs a classmethod

* update sort_xml_attr doc-string

Co-authored-by: Bill Little <bill.james.little@gmail.com>

* add jamesp to whatsnew + minor tweak

Co-authored-by: James Penn <james@jamespenn.co.uk>

* reinstate black and nox links

* Linkcheck update (#4104)

* Updated links

* Added login remark

* Removed extra space

* change to kick cirrus

* kick cirrus

* test verbose on cirrus

* Removed test settings.

Co-authored-by: Bill Little <bill.james.little@gmail.com>
Co-authored-by: Martin Yeo <40734014+trexfeathers@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: James Penn <james.penn@metoffice.gov.uk>
Co-authored-by: James Penn <james@jamespenn.co.uk>
Co-authored-by: tkknight <2108488+tkknight@users.noreply.github.com>

* Intersection bounds fix (replacement PR) (#4059)

* fix intersection out of bounds point

* fix intersection out of bounds point take 2

* add referencing comment

* bootstrap ci for 3.0.x (#4154)

* add cirrus-ci docker support

* wip

* wip

* wip

* wip

* wip

* add pip

* revert docker

* fix add_weekday (#32)

* fix add_weekday

* fix black link

* fix link

Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com>

* Tweak to speed up dask wrapping of netcdf variables (#4135)

* Use 'meta' in da.from_array to stop it sampling netcdf variables, which is quite slow.

* Fix PR number.

* Fix test.

* Review changes.

* Update docs/iris/src/whatsnew/3.0.2.rst

Co-authored-by: lbdreyer <lbdreyer@users.noreply.github.com>

* Fb fix cube coord arithmetic (#4159)

* fix coord with cube arithmetic

* add coord arithmetic test coverage

* add a whatsnew entry

* Pp daskfix (#4141)

* Remove workaround when dask-wrapping PP data, obsoleted by #4135.

* Remove old slice testing

* Add whats new

* move whitespace?

* missing line

Co-authored-by: lbdreyer <laura.dreyer@metoffice.gov.uk>

* add release date to v3.0.2 whatsnew (#4160)

* update readme logo img src and href (#4006) (#4216)

* In cube.intersection, find split cells using a tolerant equality check (#4220)

* In cube.intersection, find split cells using a tolerant equality check

* remove unused var

* Add bounds check to tests; add what's new

* Fix whats new; update version number

* Update 3.0.3.rst

Update release date in `3.0.3.rst`

* Wide cubestr fix 3v0vx v2 (#4233)

* Widen cube printout for long ancil or cell-measure names.

* Adjust result for fixed cube-units printout.

* Added whatsnew.

* Include newest whatsnew in index.

* Review: fix whatsnew structure.

* Fix initial sections display.

* Fix some typos in the cube maths docs (#4248)

* (More of) Wide cubestr fix 3v0vx v2 (#4238)

* Fix whatsnew for #4233.

* Move 'empty slicings' whatsnew entry to 3.0.2 section.

* unpin cftime (#4222)

* Test wrangling vs v3.0.x (#4249)

* test changes

* add awol init

* rename system test cases

* fix PartialDateTime tests

* fix typo

* add whatsnew

* Fix mergeback PR #4035

* Fix mergeback PR #4035 tests

* Update mergeback nox conda-lock files

Co-authored-by: tkknight <2108488+tkknight@users.noreply.github.com>
Co-authored-by: Zeb Nicholls <zebedee.nicholls@climate-energy-college.org>
Co-authored-by: Martin Yeo <40734014+trexfeathers@users.noreply.github.com>
Co-authored-by: Jon Seddon <17068361+jonseddon@users.noreply.github.com>
Co-authored-by: Ruth Comer <ruth.comer@metoffice.gov.uk>
Co-authored-by: Patrick Peglar <patrick.peglar@metoffice.gov.uk>
Co-authored-by: James Penn <james@jamespenn.co.uk>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: James Penn <james.penn@metoffice.gov.uk>
Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com>
Co-authored-by: lbdreyer <lbdreyer@users.noreply.github.com>
Co-authored-by: lbdreyer <laura.dreyer@metoffice.gov.uk>
@trexfeathers trexfeathers deleted the fix_anomaly_linscale branch August 31, 2021 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants