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:
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.