This website is for Vega-Lite v3. Go to the main Vega-Lite homepage for the latest release.

Calculate Residuals

A dot plot showing each movie in the database, and the difference from the average movie rating. The display is sorted by year to visualize everything in sequential order. The graph is for all Movies before 2019.

View this example in the online editor

Vega-Lite JSON Specification

{
  "$schema": "https://vega.github.io/schema/vega-lite/v3.json",
  "description": "A dot plot showing each movie in the database, and the difference from the average movie rating. The display is sorted by year to visualize everything in sequential order. The graph is for all Movies before 2019.",
  "data": {
    "url": "data/movies.json"
  },
  "transform": [
    {"filter": "datum.IMDB_Rating != null"},
    {"filter": {"timeUnit": "year", "field": "Release_Date", "range": [null, 2019]}},
    {
      "joinaggregate": [{
        "op": "mean",
        "field": "IMDB_Rating",
        "as": "AverageRating"
      }]
    },
    {
      "calculate": "datum.IMDB_Rating - datum.AverageRating",
      "as": "RatingDelta"
    }
  ],
  "mark": "point",
  "encoding": {
    "x": {
      "field": "Release_Date",
      "type": "temporal"
    },
    "y": {
      "field": "RatingDelta",
      "type": "quantitative",
      "axis": {"title": "Rating Delta"}
    }
  }
}