Repository navigation
FIX: Space automatic contour levels logarithmically under a log norm - #168
Merged
Merged
Conversation
Automatic contour levels were always spaced linearly, so a field spanning several decades seen through a colour scale with a logarithmic norm had all its isolines in its top decade, in nearly one colour. Under a logarithmic norm, automatic levels are now chosen strictly inside the range of the positive values of the field, as Matplotlib's LogLocator places them: the decades, thinned to at most the requested count; failing two decades, 1, 2 and 5 times each decade; then 1 to 9 times each decade; then linear levels. A filled band under a logarithmic norm is coloured by its geometric middle, so that its colour matches the middle of its span on the bar. Band edges supplied by a discrete scale are unaffected. Closes #167
thclark
force-pushed
the
log-contour-levels
branch
from
October 26, 2026 12:42
4979077 to
d04cb28
Compare
thclark
added a commit
that referenced
this pull request
Oct 26, 2026
…168) Automatic contour levels were always spaced linearly, so a field spanning several decades seen through a colour scale with a logarithmic norm had all its isolines in its top decade, in nearly one colour. Under a logarithmic norm, automatic levels are now chosen strictly inside the range of the positive values of the field, as Matplotlib's LogLocator places them: the decades, thinned to at most the requested count; failing two decades, 1, 2 and 5 times each decade; then 1 to 9 times each decade; then linear levels. A filled band under a logarithmic norm is coloured by its geometric middle, so that its colour matches the middle of its span on the bar. Band edges supplied by a discrete scale are unaffected. Closes #167
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automatic contour levels are now spaced logarithmically when a contour's colour scale has a logarithmic norm. The fix ships with the bars and histograms release (0.16.0), so this PR targets the epic trunk. The patch bump to 0.15.1 that it carried for a release from
mainhas been dropped.Before and after
Before,
contour_levelsincrates/ironlab-scene/src/compile/artists.rsalways placed linear levels. A field spanning several decades therefore had all its isolines in its top decade. In the issue's reproduction, the levels were 100, 200, …, 900.Under a logarithmic norm,
Levels::Auto, and a contour with no levels of its own on a continuous scale, now choose levels strictly inside the range of the field's positive values. They are chosen in this order:The reproduction now draws isolines at 0.1, 1, 10 and 100.
Band colours
A filled band under a logarithmic norm now takes the colour of its geometric middle, rather than its arithmetic middle, so that it matches its place on the colourbar.
Unchanged and documented
A discrete scale's band edges are unchanged. The
contoursection of the figure schema reference documents the new levels.Closes #167