Skip to content

Commit 3001294

Browse files
committed
week 8 code
1 parent 1e28057 commit 3001294

1 file changed

Lines changed: 119 additions & 0 deletions

File tree

src/class_code/week_8.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,122 @@
22
title: "Week 8: Data Types <> Scales <> Marks"
33
toc: true
44
---
5+
6+
7+
```js echo
8+
Plot.plot({
9+
marks: [
10+
// Plot.dot(olympians, { x: "height", y: "weight", fill: "sex" })
11+
Plot.rectY(
12+
olympians,
13+
Plot.binX(
14+
{ y: "count" },
15+
// { x: "weight" }
16+
{ x: { thresholds: 20, value: "weight"}, tip: true }
17+
)
18+
)
19+
]
20+
})
21+
```
22+
23+
```js echo
24+
Plot.plot({
25+
marks: [
26+
// Plot.dot(olympians, { x: "height", y: "weight", fill: "sex" })
27+
Plot.barY(
28+
olympians,
29+
Plot.groupX(
30+
{ y: "count" },
31+
{ x: "weight", tip: true }
32+
)
33+
)
34+
]
35+
})
36+
```
37+
38+
39+
```js echo
40+
const letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"];
41+
42+
display(Plot.plot({
43+
// height: 200,
44+
// width: 200,
45+
x: {
46+
// type: "band",
47+
// type: "point",
48+
domain: letters,
49+
grid: true,
50+
},
51+
marks: [
52+
// Plot.frame()
53+
Plot.axisX({anchor: "top", textStroke: "pink"})
54+
]
55+
}))
56+
```
57+
58+
```js echo
59+
Plot.plot({
60+
// height: 200,
61+
// width: 200,
62+
x: {
63+
// type: "band",
64+
// type: "point",
65+
// domain: letters,
66+
domain: [1.6, 2.5],
67+
// range: [0, 100],
68+
grid: true,
69+
},
70+
marks: [
71+
// Plot.frame()
72+
Plot.dot(olympians,
73+
{ x: "height", y: "weight", fill: "sex" }
74+
)
75+
]
76+
})
77+
```
78+
79+
80+
81+
```js echo
82+
Plot.plot({
83+
x: {
84+
domain: ["Fair", "Good", "Very Good", "Ideal", "Premium"]
85+
},
86+
color: {
87+
scheme: "Blues",
88+
legend: true,
89+
label: "Average price",
90+
},
91+
marks: [
92+
Plot.cell(diamonds,
93+
Plot.group(
94+
{ fill: "mean" },
95+
{ x: "cut", y: "color", fill: "price", tip: true }
96+
))
97+
]
98+
})
99+
```
100+
101+
102+
103+
104+
105+
106+
107+
108+
109+
110+
111+
112+
113+
114+
115+
116+
117+
118+
119+
120+
121+
122+
123+

0 commit comments

Comments
 (0)