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

Is there away to plot each point with a specifiy RGB or aRGB value? I have the colors already computed, so I do not need to use ranges, also the color range is not linear for my data.

Alice
  • 33
  • 3

1 Answers1

2

I'm not certain how this maps onto the Vegas syntax, but in Vega-Lite you can do this by passing color codes as data, and setting the color scale to null. For example:

{
  "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 output

jakevdp
  • 77,104
  • 11
  • 125
  • 160
  • Thank you. I found a workaround with your info. `encodeColor(field="color",Nominal,scale=Scale()).toJson.replaceFirst("\\{\\s*\\}","null")` It's not perfect but it does the job. Maybe somebody knows a better solution that would be great. – Alice Aug 15 '18 at 02:54