Marginal Histograms

Marginal histograms show the counts along the x and y dimension.

View this example in the online editor

Vega-Lite JSON Specification

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {"url": "data/movies.json"},
  "spacing": 15,
  "bounds": "flush",
  "vconcat": [{
    "mark": "bar",
    "height": 60,
    "encoding": {
      "x": {
        "bin": true,
        "field": "IMDB Rating",
        "axis": null
      },
      "y": {
        "aggregate": "count",
        "scale": {
          "domain": [0,1000]
        },
        "title": ""
      }
    }
  }, {
    "spacing": 15,
    "bounds": "flush",
    "hconcat": [{
      "mark": "rect",
      "encoding": {
        "x": {"bin": true, "field": "IMDB Rating"},
        "y": {"bin": true, "field": "Rotten Tomatoes Rating"},
        "color": {"aggregate": "count"}
      }
    }, {
      "mark": "bar",
      "width": 60,
      "encoding": {
        "y": {
          "bin": true,
          "field": "Rotten Tomatoes Rating",
          "axis": null
        },
        "x": {
          "aggregate": "count",
          "scale": {"domain": [0,1000]},
          "title": ""
        }
      }
    }]
  }],
  "config": {
    "view": {
      "stroke": "transparent"
    }
  }
}