Skip to content

Instantly share code, notes, and snippets.

@hawleylin
Created March 25, 2020 16:13
Show Gist options
  • Save hawleylin/9626b2f8c16b9477d8b5705d8ef7a5a4 to your computer and use it in GitHub Desktop.
Save hawleylin/9626b2f8c16b9477d8b5705d8ef7a5a4 to your computer and use it in GitHub Desktop.
Make a plot showing how the trip duration is related to the hour of the day. You could colour by usertype. You'll see that your plot will be compressed because of some very long durations, so only use the trips that have a duration of less than 5,000.
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "Assignment 1st graph",
"width": 600,
"height": "container",
"padding": 5,
"data": {
"url": "https://raw.githubusercontent.com/vda-lab/vda-lab.github.io/master/assets/station_366.json"
},
"transform": [
{
"filter": {"field": "tripduration", "lt": "5000"}
},
{"calculate": "hours(datum.starttime)", "as": "hour"}
],
"mark": {"type": "point", "filled": true},
"encoding": {
"x": {"field": "hour", "type": "quantitative"},
"y": {"field": "tripduration", "type": "quantitative"},
"color": {"field": "usertype", "type": "nominal"}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment