Search code examples
vega-litevega

Why am I seeing an empty density plot, despite no errors in the editor log?


As a learning exercise I decided to try plotting a density plot of continuously-compounded daily returns of the Nasdaq 100 index for calendar year 2020. I am unable to get vega-lite to produce any visualization, and yet there are no errors in the online editor. I'm just inexplicably given an empty plot.

empty vega-lite plot

Because of the embedded data, the plot spec is some 2500 lines long, so I've saved it as a gist: https://gist.github.com/nathanvy/2c080ee0b7e93b11e544c5275d31f2b1

What am I missing?


Solution

  • Change logreturn to value:

    enter image description here

     "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
      "width": 300,
      "height": 300,
      "title": "Nasdaq 100 (NDX) Log Returns, 2020",
      "mark": "area",
      "transform": [{"density": "logreturn"}],
      "encoding": {
        "x": {
          "field": "value",
          "title": "Logarithmic Daily Return",
          "type": "quantitative"
        },
        "y": {
          "field": "density",
          "title": "Probability of Return",
          "type": "quantitative"
        }
      }