あなたが互いの上に複数のポイントの種類を層に"layers"
仕様を使用することができます。これは比較的新しいですので、多くの例ではベガ-Liteのウェブサイト上ではまだ存在していないが、ここでは例です:
{
"data": {
"values": [
{"x": 1,"y": 2},
{"x": 2,"y": 4},
{"x": 3,"y": 5},
{"x": 4,"y": 3},
{"x": 5,"y": 4}
]
},
"layers": [
{
"encoding": {
"x": {"type": "quantitative","field": "x"},
"y": {"type": "quantitative","field": "y"}
},
"mark": "line",
"config": {"mark": {"color": "#1f77b4"}}
},
{
"encoding": {
"x": {"type": "quantitative","field": "x"},
"y": {"type": "quantitative","field": "y"}
},
"mark": "point",
"config": {"mark": {"color": "#ff7f0e"}}
}
]
}
![enter image description here](https://i.stack.imgur.com/B9a5e.png)
各層は、グローバルデータを参照するエンコーディングです。各レイヤー内で異なるデータを指定することもできます。
上記の仕様は、Vega-Liteバージョン1.xでは正しいことに注意してください。 Vega-Liteバージョン2.xでは、"layers"
が"layer"
に変更されました。
現在の回答はvega-lite2では機能しませんのでご注意ください。動作する回答をご覧ください:https://stackoverflow.com/questions/45160007/how-to-plot-several-variables - vega-liteを使った軸上で –