symmetric diverging scales by domain extension #563
Merged
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.
Rather than truncating the interpolator, this extends the domain so that it is symmetric around the pivot. While the effect is the same internally, this has two improvements.
First, it fixes #562 by returning a domain that is already symmetric, and hence applying the (default) symmetric transform again is idempotent and has no effect.
Second, it makes it easier to produce a good color legend for symmetric diverging scales. With the previous approach, you’d see something like this:
While strictly accurate, it’s a bit visually unsettling and difficult to interpret. The lower half of the legend is given equal visual space to the upper half, but covers a smaller range of values ([-0.78, 0] vs. [0, 1.35]). Under the new approach in this PR, you’d instead get:
The extended domain includes values that are not present in the chart, but the resulting interpolator no longer needs transformation, and the legend is much easier to interpret.
In retrospect, I now realize why you had symmetric = false when exposing diverging scales. 😅 But while returning symmetric = false would also fix #562, I think it’s likely to be confusing if people inspect the exposed diverging scale, and wonder why is says it’s asymmetric when you asked it to be symmetric. The approach here avoids that confusion, and makes it easier to produce a good color legend.