Skip to content

Instantly share code, notes, and snippets.

@alex-rind
Last active May 7, 2021 16:29
Show Gist options
  • Select an option

  • Save alex-rind/92766e69bd22fe8406308e1912bbeb4e to your computer and use it in GitHub Desktop.

Select an option

Save alex-rind/92766e69bd22fe8406308e1912bbeb4e to your computer and use it in GitHub Desktop.
scatter plot of blood pressure measurement with target range
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "scatter plot of blood pressure measurement with target range",
"width": 300,
"height": 180,
"padding": {"left": 5, "top": 5, "right": 50, "bottom": 5},
"data": {
"values": [
{"sex": "male", "BP systolic": 120, "BP diastolic": 80, "glucose": 190, "bmi": 28},
{"sex": "male", "BP systolic": 130, "BP diastolic": 90, "glucose": 95, "bmi": 24},
{"sex": "male", "BP systolic": 160, "BP diastolic": 110, "glucose": 150, "bmi": 34},
{"sex": "male", "BP systolic": 175, "BP diastolic": 105, "glucose": 140, "bmi": 34},
{"sex": "male", "BP systolic": 110, "BP diastolic": 72, "glucose": 90, "bmi": 24},
{"sex": "male", "BP systolic": 95, "BP diastolic": 68, "glucose": 90, "bmi": 24},
{"sex": "female", "BP systolic": 145, "BP diastolic": 90, "glucose": 80, "bmi": 28},
{"sex": "female", "BP systolic": 185, "BP diastolic": 120, "glucose": 140, "bmi": 31},
{"sex": "female", "BP systolic": 128, "BP diastolic": 85, "glucose": 140, "bmi": 31},
{"sex": "female", "BP systolic": 115, "BP diastolic": 70, "glucose": 120, "bmi": 16},
{"sex": "female", "BP systolic": 88, "BP diastolic": 62, "glucose": 90, "bmi": 16},
{"sex": "female", "BP systolic": 125, "BP diastolic": 80, "glucose": 130, "bmi": 22}
]
},
"layer": [
{
"mark": {
"type": "rect",
"fill": "peachpuff",
"fillOpacity": 0.1
},
"encoding": {
"x": {"datum": 90 , "scale": {"domain": [80,200]}},
"x2": {"datum": 140 },
"y": {"datum": 60 , "scale": {"domain": [50,130]}},
"y2": {"datum": 90 }
}
},
{
"mark": {
"type": "point",
"filled": true
},
"encoding": {
"x": {
"field": "BP systolic",
"type": "quantitative",
"scale": {"domain": [80,200]},
"axis": {"grid": true},
"title": "Blood Pressure Systolic"
},
"y": {
"field": "BP diastolic",
"type": "quantitative" ,
"scale": {"domain": [50,130]},
"axis": {"grid": true},
"title": "Blood Pressure Diastolic"
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment