如何设置存储在数据字段中的线条颜色? 在Vega中,我做了:
marks :[
{
encode: {
enter: {
...
stroke: {field: "color"}
}
}
}
]
Vega-Lite中有类似的方法吗?
答案 0 :(得分:0)
您可以使用带有color
标记的line
编码。 vega-lite网站上有一些示例;相关的一个是Multi Series Line Chart:
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"description": "Stock prices of 5 Tech Companies over Time.",
"data": {"url": "data/stocks.csv"},
"mark": "line",
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "price", "type": "quantitative"},
"color": {"field": "symbol", "type": "nominal"}
}
}