Forum Discussion
AdamMG
2 years agoHelper I
Vega Lite - scatter plot
Hi Everyone. Simple question 😉 How in Vega Lite draw line/rule (x=y) on scatterplot chart (basically line in 45 degrees)
lbendlin
2 years agoSuper User
Find the max x and y values in your data, take the largest, and then add a layer that draws from 0 to that point.
Here is a simplified version:
{
"layer": [
{
"data": {"name": "dataset"},
"mark": "point",
"encoding": {
"y": {
"field": "y",
"type": "quantitative"
},
"x": {
"field": "x",
"type": "quantitative"
}
}
},
{
"data": {
"values": [
{"x": 0, "y": 0},
{"x": 4, "y": 4}
]
},
"mark": {
"type": "line",
"from": {"data": "data2"}
},
"encoding": {
"y": {
"field": "y",
"type": "quantitative"
},
"x": {
"field": "x",
"type": "quantitative"
}
}
}
]
}