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

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/v4.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"
    }
  }
}