question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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):

Reproduction

When I add a -1 value to the data set, it renders just perfect:

Add-negative-one

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:

Domain-union-with-zero

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
domoritzcommented, May 27, 2020

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.

0reactions
sacundimcommented, Jun 2, 2020

Thanks guys!

Read more comments on GitHub >

github_iconTop Results From Across the Web

altair.Scale — Altair 4.2.0 documentation
This property can be useful for setting a midpoint for diverging color scales. The domainMid property is only intended for use with scales...
Read more >
When to use sequential and when to use diverging color scales
Diverging shades let you see more differences in the data than sequential scales. That's because the number range you show with one gradient...
Read more >
How to manually set a diverging color range - altair
The easiest approach would be to set range='diverging' , or to use one of the built-in diverging color schemes. For example:
Read more >
prefers-color-scheme - CSS: Cascading Style Sheets | MDN
The prefers-color-scheme CSS media feature is used to detect if a user has requested light or dark color themes.
Read more >
11 Colour scales and legends | ggplot2
Because colour is complex, the chapter starts with a. ... what colour is used for missing values (including values outside the range of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found