-
Notifications
You must be signed in to change notification settings - Fork 629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect Color for Ordinal Fields #1732
Comments
Using "ordinal" without custom domain doesn't produce the right order for color scale.
Thus, we should add custom domain.
However, this causes two problems:
Making the scale type = Providing custom range (e.g., GnBl from color brewer) now gives nice output, but still in a wrong order.
Temporary WorkaroundFor now, setting data type to Users might find colorbrewer useful.
TODO
IMHO, we should avoid c1 and c2 unless it is necessary. (@domoritz, I'm assigning this to you since I guess you'll be the one who handles color scale migration to Vega 3.) |
Note this occurs when Here's another example that came up in vega/altair#245 (comment): {
"data": {
"url": "https://raw.githubusercontent.com/dhimmel/biorxiv-licenses/4ad9659e4fc823f4c491e13be4505248df5c1ab6/figure/license-vs-time/vega-lite-data.json"
},
"config": {
"mark": {
"stacked": "normalize"
}
},
"encoding": {
"color": {
"field": "license",
"scale": {
"domain": [
"CC BY",
"CC BY-ND",
"CC BY-NC",
"CC BY-NC-ND",
"None"
],
"type": "ordinal"
},
"type": "nominal"
},
"x": {
"axis": {
"axisWidth": 0.0,
"format": "%Y",
"labelAngle": 0.0,
"tickSize": 0.0
},
"field": "date",
"scale": {
"nice": "month"
},
"timeUnit": "yearmonth",
"title": " ",
"type": "temporal"
},
"y": {
"aggregate": "count",
"axis": {
"axisWidth": 0.0,
"grid": false,
"labels": false,
"ticks": 0.0
},
"field": "*",
"title": "Proportion of Preprints",
"type": "quantitative"
}
},
"mark": "area"
} Notice how the legend ordering doesn't match the ordering of the normalized area marks. |
Index scales should work for specifically this purpose. This means we will support it in Vega-Lite 2.0 because we need Vega 3 scales. There seem to be a few issues with index scales that need to be resolved first vega/vega#667 |
Addressed in #1746 (pending review) |
From vega/altair#245, using ordinal fields with ordinal color seems to be incorrect.
The text was updated successfully, but these errors were encountered: