Vega-lite: Marginal histograms

Created on 24 Jan 2018  路  5Comments  路  Source: vega/vega-lite

All 5 comments

{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "data": {"url": "data/movies.json"},
  "vconcat": [{
    "mark": "bar",
    "height": 100,
    "encoding": {
      "x": {
        "bin": true,
        "field": "IMDB_Rating",
        "type": "quantitative",
        "axis": null
      },
      "y": {
        "aggregate": "count",
        "type": "quantitative"
      }
    }
  }, {
    "hconcat": [{
      "mark": "rect",
      "encoding": {
        "x": {
          "bin": true,
          "field": "IMDB_Rating",
          "type": "quantitative"
        },
        "y": {
          "bin": true,
          "field": "Rotten_Tomatoes_Rating",
          "type": "quantitative"
        },
        "color": {
          "aggregate": "count",
          "type": "quantitative"
        }
      }
    }, {
      "mark": "bar",
      "width": 100,
      "encoding": {
        "y": {
          "bin": true,
          "field": "Rotten_Tomatoes_Rating",
          "type": "quantitative",
          "axis": null
        },
        "x": {
          "aggregate": "count",
          "type": "quantitative"
        }
      }
    }]
  }],
  "config": {
    "range": {
      "heatmap": {
        "scheme": "greenblue"
      }
    },
    "view": {
      "stroke": "transparent"
    }
  }
}

screen shot 2018-01-23 at 20 18 20

This works pretty well. I wonder whether we should support customization of the layout in hconcat and vconcat so that we can remove the padding. hconcat could have a layout property or all layout properties could be top-level properties of the concat. Thoughts @kanitw?

I think someone need to prototype the syntax for the underlying layout in Vega soon.
There are also layout transforms that may make the term a bit overloaded.

Btw, I don't understand what's the issue here. Why don't you just add it? (What's the point of waiting? -- New people in the future will have to add their own new examples anyway.)
A more interesting tasks is to modify your code to add box plot and dot plots to the margin instead.

I agree with @domoritz's suggestion that it would be useful to be able to get rid of the margins between the plots. Another use case is the so-called rug plot or dot-dash plot, in which ideally the marginal tick marks touch the domain of the main scatter plot.

Maybe allow the padding property for each unit spec of a composed spec ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paintdog picture paintdog  路  4Comments

mcnuttandrew picture mcnuttandrew  路  3Comments

swanderz picture swanderz  路  4Comments

mcnuttandrew picture mcnuttandrew  路  3Comments

ijlyttle picture ijlyttle  路  3Comments