Why is this @vlplot blank?

I use this command:

DataFramesMeta.@select(@where(dftrans, .! ismissing.(:PreScore) .& .! ismissing.(:Group)), :Group,PreScore = Float64.(:PreScore)) |> @vlplot(mark={:area, fillOpacity=.5},x={"PreScore:q",scale={domain=[0,50]}},y="density:q",color="Group:n", transform = [{density = "PreScore",bandwidth=.5,groupby=["Group"]}])

Which gives me the following useless plot:

image

When I click to show the compiled vegalite code it’s as follows in the details section: This looks ok to me?

The Compiled VegaLite
{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "background": "white",
  "padding": 5,
  "width": 200,
  "height": 200,
  "style": "cell",
  "data": [
    {
      "name": "source_0",
      "values": [
        {"Group": "Experimental", "PreScore": 22},
        {"Group": "Experimental", "PreScore": 29},
        {"Group": "Experimental", "PreScore": 27},
        {"Group": "Experimental", "PreScore": 26},
        {"Group": "Experimental", "PreScore": 19},
        {"Group": "Experimental", "PreScore": 20},
        {"Group": "Experimental", "PreScore": 22},
        {"Group": "Experimental", "PreScore": 23},
        {"Group": "Experimental", "PreScore": 22},
        {"Group": "Experimental", "PreScore": 21},
        {"Group": "Experimental", "PreScore": 24},
        {"Group": "Experimental", "PreScore": 24},
        {"Group": "Experimental", "PreScore": 26},
        {"Group": "Experimental", "PreScore": 20},
        {"Group": "Experimental", "PreScore": 13},
        {"Group": "Experimental", "PreScore": 27},
        {"Group": "Experimental", "PreScore": 21},
        {"Group": "Experimental", "PreScore": 22},
        {"Group": "Experimental", "PreScore": 35},
        {"Group": "Experimental", "PreScore": 23},
        {"Group": "Experimental", "PreScore": 25},
        {"Group": "Experimental", "PreScore": 24},
        {"Group": "Experimental", "PreScore": 27},
        {"Group": "Experimental", "PreScore": 22},
        {"Group": "Experimental", "PreScore": 24},
        {"Group": "Experimental", "PreScore": 24},
        {"Group": "Experimental", "PreScore": 28},
        {"Group": "Experimental", "PreScore": 18},
        {"Group": "Experimental", "PreScore": 26},
        {"Group": "Experimental", "PreScore": 22},
        {"Group": "Experimental", "PreScore": 34},
        {"Group": "Experimental", "PreScore": 25},
        {"Group": "Experimental", "PreScore": 21},
        {"Group": "Experimental", "PreScore": 23},
        {"Group": "Experimental", "PreScore": 23},
        {"Group": "Experimental", "PreScore": 20},
        {"Group": "Experimental", "PreScore": 26},
        {"Group": "Experimental", "PreScore": 21},
        {"Group": "Experimental", "PreScore": 20},
        {"Group": "Experimental", "PreScore": 19},
        {"Group": "Experimental", "PreScore": 25},
        {"Group": "Experimental", "PreScore": 29},
        {"Group": "Experimental", "PreScore": 32},
        {"Group": "Experimental", "PreScore": 26},
        {"Group": "Experimental", "PreScore": 20},
        {"Group": "Experimental", "PreScore": 19},
        {"Group": "Experimental", "PreScore": 26},
        {"Group": "Experimental", "PreScore": 15},
        {"Group": "Experimental", "PreScore": 27},
        {"Group": "Experimental", "PreScore": 17},
        {"Group": "Experimental", "PreScore": 21},
        {"Group": "Experimental", "PreScore": 26},
        {"Group": "Experimental", "PreScore": 22},
        {"Group": "Experimental", "PreScore": 25},
        {"Group": "Experimental", "PreScore": 29},
        {"Group": "Experimental", "PreScore": 26},
        {"Group": "Experimental", "PreScore": 28},
        {"Group": "Experimental", "PreScore": 28},
        {"Group": "Experimental", "PreScore": 26},
        {"Group": "Experimental", "PreScore": 24},
        {"Group": "Experimental", "PreScore": 25},
        {"Group": "Experimental", "PreScore": 27},
        {"Group": "Experimental", "PreScore": 18},
        {"Group": "Experimental", "PreScore": 29},
        {"Group": "Experimental", "PreScore": 17},
        {"Group": "Experimental", "PreScore": 26},
        {"Group": "Experimental", "PreScore": 23},
        {"Group": "Experimental", "PreScore": 30},
        {"Group": "Experimental", "PreScore": 17},
        {"Group": "Experimental", "PreScore": 19},
        {"Group": "Experimental", "PreScore": 14},
        {"Group": "Experimental", "PreScore": 20},
        {"Group": "Experimental", "PreScore": 21},
        {"Group": "Experimental", "PreScore": 23},
        {"Group": "Experimental", "PreScore": 14},
        {"Group": "Experimental", "PreScore": 24},
        {"Group": "Experimental", "PreScore": 26},
        {"Group": "Experimental", "PreScore": 23},
        {"Group": "Experimental", "PreScore": 22},
        {"Group": "Experimental", "PreScore": 25},
        {"Group": "Experimental", "PreScore": 24},
        {"Group": "Experimental", "PreScore": 20},
        {"Group": "Experimental", "PreScore": 23},
        {"Group": "Experimental", "PreScore": 25},
        {"Group": "Experimental", "PreScore": 24},
        {"Group": "Experimental", "PreScore": 21},
        {"Group": "Experimental", "PreScore": 21},
        {"Group": "Experimental", "PreScore": 28},
        {"Group": "Experimental", "PreScore": 31},
        {"Group": "Experimental", "PreScore": 29},
        {"Group": "Experimental", "PreScore": 25},
        {"Group": "Experimental", "PreScore": 23},
        {"Group": "Experimental", "PreScore": 13},
        {"Group": "Experimental", "PreScore": 19},
        {"Group": "Experimental", "PreScore": 22},
        {"Group": "Experimental", "PreScore": 21},
        {"Group": "Experimental", "PreScore": 25},
        {"Group": "Experimental", "PreScore": 24},
        {"Group": "Experimental", "PreScore": 28},
        {"Group": "Experimental", "PreScore": 21},
        {"Group": "Experimental", "PreScore": 24},
        {"Group": "Experimental", "PreScore": 23},
        {"Group": "Experimental", "PreScore": 23},
        {"Group": "Experimental", "PreScore": 24},
        {"Group": "Experimental", "PreScore": 27},
        {"Group": "Experimental", "PreScore": 23},
        {"Group": "Experimental", "PreScore": 23},
        {"Group": "Experimental", "PreScore": 24},
        {"Group": "Experimental", "PreScore": 15},
        {"Group": "Experimental", "PreScore": 25},
        {"Group": "Experimental", "PreScore": 30},
        {"Group": "Experimental", "PreScore": 28},
        {"Group": "Experimental", "PreScore": 28},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 19},
        {"Group": "Control", "PreScore": 28},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 28},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 28},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 32},
        {"Group": "Control", "PreScore": 29},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 28},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 17},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 19},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 19},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 17},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 27},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 29},
        {"Group": "Control", "PreScore": 27},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 26},
        {"Group": "Control", "PreScore": 19},
        {"Group": "Control", "PreScore": 26},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 26},
        {"Group": "Control", "PreScore": 33},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 19},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 27},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 18},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 18},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 19},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 19},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 39},
        {"Group": "Control", "PreScore": 18},
        {"Group": "Control", "PreScore": 29},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 17},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 28},
        {"Group": "Control", "PreScore": 17},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 19},
        {"Group": "Control", "PreScore": 15},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 17},
        {"Group": "Control", "PreScore": 27},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 16},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 13},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 16},
        {"Group": "Control", "PreScore": 16},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 36},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 15},
        {"Group": "Control", "PreScore": 28},
        {"Group": "Control", "PreScore": 29},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 17},
        {"Group": "Control", "PreScore": 29},
        {"Group": "Control", "PreScore": 28},
        {"Group": "Control", "PreScore": 27},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 18},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 18},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 26},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 28},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 17},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 26},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 27},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 27},
        {"Group": "Control", "PreScore": 15},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 15},
        {"Group": "Control", "PreScore": 26},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 16},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 26},
        {"Group": "Control", "PreScore": 26},
        {"Group": "Control", "PreScore": 28},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 17},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 35},
        {"Group": "Control", "PreScore": 14},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 17},
        {"Group": "Control", "PreScore": 16},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 32},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 19},
        {"Group": "Control", "PreScore": 28},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 28},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 16},
        {"Group": "Control", "PreScore": 18},
        {"Group": "Control", "PreScore": 27},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 28},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 32},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 33},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 19},
        {"Group": "Control", "PreScore": 26},
        {"Group": "Control", "PreScore": 38},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 18},
        {"Group": "Control", "PreScore": 16},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 31},
        {"Group": "Control", "PreScore": 18},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 19},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 27},
        {"Group": "Control", "PreScore": 16},
        {"Group": "Control", "PreScore": 27},
        {"Group": "Control", "PreScore": 30},
        {"Group": "Control", "PreScore": 30},
        {"Group": "Control", "PreScore": 26},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 30},
        {"Group": "Control", "PreScore": 31},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 19},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 18},
        {"Group": "Control", "PreScore": 19},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 9},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 28},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 19},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 25},
        {"Group": "Control", "PreScore": 17},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 26},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 17},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 28},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 26},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 27},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 29},
        {"Group": "Control", "PreScore": 22},
        {"Group": "Control", "PreScore": 29},
        {"Group": "Control", "PreScore": 15},
        {"Group": "Control", "PreScore": 14},
        {"Group": "Control", "PreScore": 21},
        {"Group": "Control", "PreScore": 24},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 26},
        {"Group": "Control", "PreScore": 23},
        {"Group": "Control", "PreScore": 20},
        {"Group": "Control", "PreScore": 27},
        {"Group": "Control", "PreScore": 29}
      ]
    },
    {
      "name": "data_0",
      "source": "source_0",
      "transform": [
        {
          "type": "formula",
          "expr": "toNumber(datum[\"PreScore\"])",
          "as": "PreScore"
        },
        {
          "type": "kde",
          "field": "PreScore",
          "bandwidth": 0.5,
          "groupby": ["Group"],
          "as": ["value", "density"]
        }
      ]
    }
  ],
  "marks": [
    {
      "name": "pathgroup",
      "type": "group",
      "from": {
        "facet": {
          "name": "faceted_path_main",
          "data": "data_0",
          "groupby": ["Group"]
        }
      },
      "encode": {
        "update": {
          "width": {"field": {"group": "width"}},
          "height": {"field": {"group": "height"}}
        }
      },
      "marks": [
        {
          "name": "marks",
          "type": "area",
          "style": ["area"],
          "sort": {"field": "datum[\"PreScore\"]"},
          "from": {"data": "faceted_path_main"},
          "encode": {
            "update": {
              "fillOpacity": {"value": 0.5},
              "orient": {"value": "vertical"},
              "fill": {"scale": "color", "field": "Group"},
              "description": {
                "signal": "\"PreScore: \" + (format(datum[\"PreScore\"], \"\")) + \"; density: \" + (format(datum[\"density\"], \"\")) + \"; Group: \" + (isValid(datum[\"Group\"]) ? datum[\"Group\"] : \"\"+datum[\"Group\"])"
              },
              "x": {"scale": "x", "field": "PreScore"},
              "y": {"scale": "y", "field": "density"},
              "y2": {"scale": "y", "value": 0},
              "defined": {
                "signal": "isValid(datum[\"PreScore\"]) && isFinite(+datum[\"PreScore\"]) && isValid(datum[\"density\"]) && isFinite(+datum[\"density\"])"
              }
            }
          }
        }
      ]
    }
  ],
  "scales": [
    {
      "name": "x",
      "type": "linear",
      "domain": [0, 50],
      "range": [0, {"signal": "width"}],
      "nice": true,
      "zero": true
    },
    {
      "name": "y",
      "type": "linear",
      "domain": {"data": "data_0", "field": "density"},
      "range": [{"signal": "height"}, 0],
      "nice": true,
      "zero": true
    },
    {
      "name": "color",
      "type": "ordinal",
      "domain": {"data": "data_0", "field": "Group", "sort": true},
      "range": "category"
    }
  ],
  "axes": [
    {
      "scale": "x",
      "orient": "bottom",
      "gridScale": "y",
      "grid": true,
      "tickCount": {"signal": "ceil(width/40)"},
      "domain": false,
      "labels": false,
      "aria": false,
      "maxExtent": 0,
      "minExtent": 0,
      "ticks": false,
      "zindex": 0
    },
    {
      "scale": "y",
      "orient": "left",
      "gridScale": "x",
      "grid": true,
      "tickCount": {"signal": "ceil(height/40)"},
      "domain": false,
      "labels": false,
      "aria": false,
      "maxExtent": 0,
      "minExtent": 0,
      "ticks": false,
      "zindex": 0
    },
    {
      "scale": "x",
      "orient": "bottom",
      "grid": false,
      "title": "PreScore",
      "labelFlush": true,
      "labelOverlap": true,
      "tickCount": {"signal": "ceil(width/40)"},
      "zindex": 0
    },
    {
      "scale": "y",
      "orient": "left",
      "grid": false,
      "title": "density",
      "labelOverlap": true,
      "tickCount": {"signal": "ceil(height/40)"},
      "zindex": 0
    }
  ],
  "legends": [{"fill": "color", "symbolType": "circle", "title": "Group"}]
}

Perhaps @davidanthoff has some idea?

I think the compiled VegaLite shows that it’s not the data manipulation, because the data seems fine in the JSON.

Here’s a minimal example of the same problem without the need for my data:

DataFrame(Group=["Experimental","Experimental","Experimental","Experimental","Control","Control","Control","Control"],
PreScore=rand(Normal(0,1),8)) |> @vlplot(mark={:area, fillOpacity=.5},x={"PreScore:q",scale={domain=[-3,3]}},y="density:q",color="Group:n", transform = [{density = "PreScore",bandwidth=.5,groupby=["Group"]}])

using DataFrames, VegaLite, Distributions

df = DataFrame(Group = ["Experimental","Experimental","Experimental","Experimental","Control","Control","Control","Control"], PreScore = rand(Normal(0, 1), 8))

df |> @vlplot(
    width=400,
    height=100,
    mark = {:area, opacity = 0.5},
    transform=[{density = "PreScore",
                bandwidth = 0.5,
                groupby = ["Group"],
                extent=[-3, 3],
                counts=true, steps=50}],
    x={"value:q", title="PreScore"},
    y= {"density:q",stack=true},
    color={"Group:n", scale={scheme=:category20}}
    )

density

I think the key bit was x={"value:q",...

I followed the example here.

Hmm… adding value:

I’m using the :q above in the minimal example, and still blank…

oh wait, you’re saying “value:q” weird. That doesn’t seem to work for me either.

Ok, weird. the thing that’s really getting me borked is that the DataFrame I’m working with actually has a column named “value” that I’m trying to do the density plot on… if I use your tip with the minimal example, it does work:

DataFrame(Group=["Experimental","Experimental","Experimental","Experimental","Control","Control","Control","Control"],
PreScore=rand(Normal(0,1),8)) |> @vlplot(mark={:area, fillOpacity=.5},x={"value:q",scale={domain=[-3,3]}},y="density:q",color="Group:n", transform = [{density = "PreScore",bandwidth=.5,groupby=["Group"]}])

that works…

I’ll have to see what’s going wrong in my “real” example.

Take a look at this example in the online Vega/Vega-lite editor here. For local use, I have cloned and built both Vega and the editor according to the github instructions without problem. And there’s a lot of info at the main site. In your case, and for this area/density encoding, if your column is named value, I suspect the encoding for x will look something like this:

"x": {"field": "value", "title": "Value"}

which I believe is saying take the value of the datum in the Value column. This goes against what I’ve done in other plots, like a time series, where the x field is the name of the column. Guess it’s time to dig into the documentation on the main Vega site.

1 Like