-
Notifications
You must be signed in to change notification settings - Fork 1
/
_viz-datasets.qmd
40 lines (35 loc) · 1000 Bytes
/
_viz-datasets.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
```{ojs}
// selector for dataset
summaries_map = new Map(Object.entries(summaries))
viewof dataset = Inputs.select(summaries_map, {label: 'Dataset'})
// transpose all data for plotting
items = transpose(dataset.items)
subjects = transpose(dataset.subjects)
metadata_trans = transpose(metadata)
```
```{ojs}
Plot = import("https://esm.sh/@observablehq/[email protected]")
// plot items
viewof item_plot = Plot.plot({
x: {label: "Item mean response"},
y: {grid: true},
marks: [
Plot.rectY(items, Plot.binX({y: "count"}, {x: "mean"})),
Plot.ruleY([0])
]
})
// plot subjects
viewof subj_plot = Plot.plot({
x: {label: "Subject mean response"},
y: {grid: true},
marks: [
Plot.rectY(subjects, Plot.binX({y: "count"}, {x: "mean"})),
Plot.ruleY([0])
]
})
// display item and subject plots side by side
html`<div style="display: flex;">
<div style="flex-basis:50%"> ${viewof item_plot} </div>
<div style="flex-basis:50%"> ${viewof subj_plot} </div>
</div>`
```