Vegas (Scala/Spark/Vega) 为每个数据点着色
Vegas (Scala/Spark/Vega) color every data point
Vegas("A scatterplot").
withDataFrame(neuronnet_activation_df).
mark(Point).
encodeX("s", Quantitative).
encodeY("d", Quantitative).
encodeColor(field="feature_0_prediction",scale=Scale(rangeNominals=List("#c41f01", "#00c610"))).
show
是否可以用特定的 RGB 或 aRGB 值绘制每个点?
我已经计算了颜色,所以我不需要使用范围,而且我的数据的颜色范围不是线性的。
我不确定这如何映射到 Vegas 语法,但在 Vega-Lite 中,您可以通过将颜色代码作为数据传递并将色标设置为 null
来实现。例如:
{
"data": {
"values": [
{"s": 1, "d": 1, "color": "#c41f01"},
{"s": 3, "d": 3, "color": "#00c610"}
]
},
"mark": {"type": "circle", "size": 200},
"encoding": {
"color": {"type": "nominal", "field": "color", "scale": null},
"x": {"type": "quantitative", "field": "s"},
"y": {"type": "quantitative", "field": "d"}
},
"$schema": "https://vega.github.io/schema/vega-lite/v2.6.0.json"
}
Vegas("A scatterplot").
withDataFrame(neuronnet_activation_df).
mark(Point).
encodeX("s", Quantitative).
encodeY("d", Quantitative).
encodeColor(field="feature_0_prediction",scale=Scale(rangeNominals=List("#c41f01", "#00c610"))).
show
是否可以用特定的 RGB 或 aRGB 值绘制每个点? 我已经计算了颜色,所以我不需要使用范围,而且我的数据的颜色范围不是线性的。
我不确定这如何映射到 Vegas 语法,但在 Vega-Lite 中,您可以通过将颜色代码作为数据传递并将色标设置为 null
来实现。例如:
{
"data": {
"values": [
{"s": 1, "d": 1, "color": "#c41f01"},
{"s": 3, "d": 3, "color": "#00c610"}
]
},
"mark": {"type": "circle", "size": 200},
"encoding": {
"color": {"type": "nominal", "field": "color", "scale": null},
"x": {"type": "quantitative", "field": "s"},
"y": {"type": "quantitative", "field": "d"}
},
"$schema": "https://vega.github.io/schema/vega-lite/v2.6.0.json"
}