-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
435 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script setup> | ||
import { coordinator } from '@uwdata/vgplot'; | ||
coordinator().clear(); | ||
</script> | ||
|
||
# Density Groups | ||
|
||
Density plots of penguin bill depths, grouped by species. The normalize parameter supporting different forms of comparison, controlling if an individual density estimate is scaled by total point mass or normalized by the sum or max of the point mass. The stack and offset parameters control stacking of density areas. | ||
|
||
<Example spec="/specs/yaml/density-groups.yaml" /> | ||
|
||
## Specification | ||
|
||
::: code-group | ||
<<< @/public/specs/esm/density-groups.js [JavaScript] | ||
<<< @/public/specs/yaml/density-groups.yaml [YAML] | ||
<<< @/public/specs/json/density-groups.json [JSON] | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as vg from "@uwdata/vgplot"; | ||
|
||
await vg.coordinator().exec([ | ||
vg.loadParquet("penguins", "data/penguins.parquet") | ||
]); | ||
|
||
const $bandwidth = vg.Param.value(20); | ||
const $normalize = vg.Param.value("none"); | ||
const $stack = vg.Param.value(false); | ||
const $offset = vg.Param.value(null); | ||
|
||
export default vg.vconcat( | ||
vg.hconcat( | ||
vg.menu({label: "Normalize", as: $normalize, options: ["none", "sum", "max"]}), | ||
vg.menu({label: "Stack", as: $stack, options: [false, true]}), | ||
vg.menu({ | ||
label: "Offset", | ||
as: $offset, | ||
options: [ | ||
{label: "none", value: null}, | ||
{label: "normalize", value: "normalize"}, | ||
{label: "center", value: "center"} | ||
] | ||
}) | ||
), | ||
vg.plot( | ||
vg.densityY( | ||
vg.from("penguins"), | ||
{ | ||
x: "bill_depth", | ||
fill: "species", | ||
fillOpacity: 0.4, | ||
bandwidth: $bandwidth, | ||
normalize: $normalize, | ||
stack: $stack, | ||
offset: $offset | ||
} | ||
), | ||
vg.marginLeft(50), | ||
vg.height(200) | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"meta": { | ||
"title": "Density Groups", | ||
"description": "Density plots of penguin bill depths, grouped by species. The normalize parameter supporting different forms of comparison, controlling if an individual density estimate is scaled by total point mass or normalized by the sum or max of the point mass. The stack and offset parameters control stacking of density areas.\n" | ||
}, | ||
"data": { | ||
"penguins": { | ||
"file": "data/penguins.parquet" | ||
} | ||
}, | ||
"params": { | ||
"bandwidth": 20, | ||
"normalize": "none", | ||
"stack": false, | ||
"offset": null | ||
}, | ||
"vconcat": [ | ||
{ | ||
"hconcat": [ | ||
{ | ||
"input": "menu", | ||
"label": "Normalize", | ||
"as": "$normalize", | ||
"options": [ | ||
"none", | ||
"sum", | ||
"max" | ||
] | ||
}, | ||
{ | ||
"input": "menu", | ||
"label": "Stack", | ||
"as": "$stack", | ||
"options": [ | ||
false, | ||
true | ||
] | ||
}, | ||
{ | ||
"input": "menu", | ||
"label": "Offset", | ||
"as": "$offset", | ||
"options": [ | ||
{ | ||
"label": "none", | ||
"value": null | ||
}, | ||
{ | ||
"label": "normalize", | ||
"value": "normalize" | ||
}, | ||
{ | ||
"label": "center", | ||
"value": "center" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"plot": [ | ||
{ | ||
"mark": "densityY", | ||
"data": { | ||
"from": "penguins" | ||
}, | ||
"x": "bill_depth", | ||
"fill": "species", | ||
"fillOpacity": 0.4, | ||
"bandwidth": "$bandwidth", | ||
"normalize": "$normalize", | ||
"stack": "$stack", | ||
"offset": "$offset" | ||
} | ||
], | ||
"marginLeft": 50, | ||
"height": 200 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
meta: | ||
title: Density Groups | ||
description: > | ||
Density plots of penguin bill depths, grouped by species. | ||
The normalize parameter supporting different forms of comparison, | ||
controlling if an individual density estimate is scaled by total point | ||
mass or normalized by the sum or max of the point mass. | ||
The stack and offset parameters control stacking of density areas. | ||
data: | ||
penguins: { file: data/penguins.parquet } | ||
params: | ||
bandwidth: 20 | ||
normalize: none | ||
stack: false | ||
offset: null | ||
vconcat: | ||
- hconcat: | ||
- input: menu | ||
label: Normalize | ||
as: $normalize | ||
options: [none, sum, max] | ||
- input: menu | ||
label: Stack | ||
as: $stack | ||
options: [false, true] | ||
- input: menu | ||
label: Offset | ||
as: $offset | ||
options: | ||
- { label: none, value: null } | ||
- { label: normalize, value: normalize } | ||
- { label: center, value: center } | ||
- plot: | ||
- mark: densityY | ||
data: { from: penguins } | ||
x: bill_depth | ||
fill: species | ||
fillOpacity: 0.4 | ||
bandwidth: $bandwidth | ||
normalize: $normalize | ||
stack: $stack | ||
offset: $offset | ||
marginLeft: 50 | ||
height: 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as vg from "@uwdata/vgplot"; | ||
|
||
await vg.coordinator().exec([ | ||
vg.loadParquet("penguins", "data/penguins.parquet") | ||
]); | ||
|
||
const $bandwidth = vg.Param.value(20); | ||
const $normalize = vg.Param.value("none"); | ||
const $stack = vg.Param.value(false); | ||
const $offset = vg.Param.value(null); | ||
|
||
export default vg.vconcat( | ||
vg.hconcat( | ||
vg.menu({label: "Normalize", as: $normalize, options: ["none", "sum", "max"]}), | ||
vg.menu({label: "Stack", as: $stack, options: [false, true]}), | ||
vg.menu({ | ||
label: "Offset", | ||
as: $offset, | ||
options: [ | ||
{label: "none", value: null}, | ||
{label: "normalize", value: "normalize"}, | ||
{label: "center", value: "center"} | ||
] | ||
}) | ||
), | ||
vg.plot( | ||
vg.densityY( | ||
vg.from("penguins"), | ||
{ | ||
x: "bill_depth", | ||
fill: "species", | ||
fillOpacity: 0.4, | ||
bandwidth: $bandwidth, | ||
normalize: $normalize, | ||
stack: $stack, | ||
offset: $offset | ||
} | ||
), | ||
vg.marginLeft(50), | ||
vg.height(200) | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"meta": { | ||
"title": "Density Groups", | ||
"description": "Density plots of penguin bill depths, grouped by species. The normalize parameter supporting different forms of comparison, controlling if an individual density estimate is scaled by total point mass or normalized by the sum or max of the point mass. The stack and offset parameters control stacking of density areas.\n" | ||
}, | ||
"data": { | ||
"penguins": { | ||
"type": "parquet", | ||
"file": "data/penguins.parquet" | ||
} | ||
}, | ||
"params": { | ||
"bandwidth": 20, | ||
"normalize": "none", | ||
"stack": false, | ||
"offset": null | ||
}, | ||
"vconcat": [ | ||
{ | ||
"hconcat": [ | ||
{ | ||
"input": "menu", | ||
"label": "Normalize", | ||
"as": "$normalize", | ||
"options": [ | ||
"none", | ||
"sum", | ||
"max" | ||
] | ||
}, | ||
{ | ||
"input": "menu", | ||
"label": "Stack", | ||
"as": "$stack", | ||
"options": [ | ||
false, | ||
true | ||
] | ||
}, | ||
{ | ||
"input": "menu", | ||
"label": "Offset", | ||
"as": "$offset", | ||
"options": [ | ||
{ | ||
"label": "none", | ||
"value": null | ||
}, | ||
{ | ||
"label": "normalize", | ||
"value": "normalize" | ||
}, | ||
{ | ||
"label": "center", | ||
"value": "center" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"plot": [ | ||
{ | ||
"mark": "densityY", | ||
"data": { | ||
"from": "penguins" | ||
}, | ||
"x": "bill_depth", | ||
"fill": "species", | ||
"fillOpacity": 0.4, | ||
"bandwidth": "$bandwidth", | ||
"normalize": "$normalize", | ||
"stack": "$stack", | ||
"offset": "$offset" | ||
} | ||
], | ||
"marginLeft": 50, | ||
"height": 200 | ||
} | ||
] | ||
} |
Oops, something went wrong.