domainMid of diverging color scheme ignored when it falls outside data range
See original GitHub issue(See also: https://github.com/vega/vega-lite/issues/6544)
I’ve made a chart that uses a diverging color scheme with "domainMid": 0
with the expectation that this would render negative numbers with the lower half of the color scheme and positive ones with the upper half. But when the data contains only positive numbers, Vega warns in the console that domainMid
falls outside of the domain:
WARN Scale domainMid exceeds domain min or max. 0
…and proceeds to map positive numbers to the whole domain, and in a very coarse fashion that only seems to use the extreme colors from the range, as illustrated by this example (which I’ve tried to simplify as much as I could):
When I add a -1 value to the data set, it renders just perfect:
When I filed a ticket on this against Vega-Lite, @domoritz offered a workaround on Vega-Lite that compiles to a Vega spec similar to this one, with a domain
to which [0]
has been added:
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Thank you for filing the issue.
@jheer I think the problem is best fixed in Vega (if at all) so the behavior is consistent across tools but if you disagree, we can see how we can address it in Vega-Lite instead.
Thanks guys!