-
-
Notifications
You must be signed in to change notification settings - Fork 668
Open
Labels
Description
Bug Description
When using a diverging color scale as described in the docs, the color scheme is stuck at default blueorange
Below, I unsuccessfully tried to change the color scale to redblue (editor)
{
"$schema": "https://vega.github.io/schema/vega-lite/v6.json",
"data": {
"values": [
{"x": 3, "y": 30, "value": -10},
{"x": 4, "y": 40, "value": 0},
{"x": 5, "y": 50, "value": 10}
]
},
"mark": "bar",
"encoding": {
"x": {"field": "x", "type": "nominal"},
"color": {
"field": "value",
"type": "quantitative",
"scale": {"range": "diverging", "scheme": "redblue", "domainMid": 5}
}
}
}Workaround: I get the intended behavior by removing "range": "diverging", and just set the custom "domainMid": 5.
{
"$schema": "https://vega.github.io/schema/vega-lite/v6.json",
"data": {
"values": [
{"x": 3, "y": 30, "value": -10},
{"x": 4, "y": 40, "value": 0},
{"x": 5, "y": 50, "value": 10}
]
},
"mark": "bar",
"encoding": {
"x": {"field": "x", "type": "nominal"},
"color": {
"field": "value",
"type": "quantitative",
"scale": {
"domainMid": 5,
"scheme": "redblue"
}
}
}
}
Potential next steps
- Should
range: divergingbe updated to allow setting a named color scheme for the range? - If
divergingis meant to always use this palette, does it make sense to update the docs for scale with an example of how to get a diverging color palette by choosing a diverging scheme from the collection, and setting a customdomainMid?