3
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 值绘制每个点?我已经计算了颜色,所以我不需要使用范围,而且颜色范围对于我的数据也不是线性的。

4

1 回答 1

2

我不确定这如何映射到 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"
}

Vega-Lite 输出

于 2018-08-14T17:48:42.040 回答