Platform
Solutions
Resources
Pricing
Sign in
Sign up
Fil
Vocateur.
Workspace
Fork
Published
Plot
By
Fil
Edited
May 16, 2022
4 stars
Insert cell
Insert cell
Insert cell
3
// curve distribution function suggested by @mootari, thanks!
population
=
{
const
random
=
d3
.
randomLcg
(
42
)
;
const
curve
=
(
t
)
=>
(
1
-
t
**
0.4
)
**
0.75
;
return
Array
.
from
(
{
length
:
40
}
,
(
)
=>
(
{
age
:
(
curve
(
random
(
)
)
*
100
)
|
0
,
hand
:
[
"Y"
,
"L"
,
"R"
,
"Z"
]
[
(
0.9
+
random
(
)
*
2.2
)
|
0
]
}
)
)
;
}
Insert cell
Insert cell
Insert cell
Plot
.
plot
(
{
height
:
100
,
marks
:
[
Plot
.
barY
(
population
,
Plot
.
groupX
(
{
y
:
"count"
}
,
{
x
:
"age"
}
)
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
height
:
100
,
marks
:
[
Plot
.
barY
(
population
,
Plot
.
groupX
(
{
y
:
"count"
}
,
{
x
:
(
d
)
=>
`${
5
*
Math
.
floor
(
d
.
age
/
5
)
}-${
5
+
5
*
Math
.
floor
(
d
.
age
/
5
)
}`
}
)
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
height
:
300
,
marks
:
[
Plot
.
rectY
(
population
,
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"age"
,
thresholds
:
[
5
,
10
,
18
,
25
,
35
,
50
,
65
]
}
)
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
height
:
100
,
marks
:
[
Plot
.
rect
(
population
,
Plot
.
stackY
(
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"age"
,
thresholds
:
90
}
)
)
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
height
:
250
,
marks
:
[
Plot
.
rect
(
population
,
Plot
.
stackY
(
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"age"
,
interval
:
5
}
)
)
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
height
:
250
,
marks
:
[
Plot
.
rectY
(
population
,
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"age"
,
fill
:
"hand"
,
interval
:
5
}
)
)
,
Plot
.
ruleY
(
[
0
]
)
]
,
color
:
{
legend
:
true
}
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
height
:
250
,
marks
:
[
Plot
.
rectY
(
population
,
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"age"
,
fill
:
(
d
)
=>
(
[
"R"
,
"L"
]
.
includes
(
d
.
hand
)
?
d
.
hand
:
"other"
)
,
interval
:
5
}
)
)
,
Plot
.
ruleY
(
[
0
]
)
]
,
color
:
{
legend
:
true
}
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Plot
.
plot
(
{
height
:
250
,
marks
:
[
Plot
.
rectY
(
population
,
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"age"
,
filter
:
(
d
)
=>
d
.
age
>=
ageMin
&&
d
.
age
<
ageMax
,
fill
:
(
d
)
=>
(
[
"R"
,
"L"
]
.
includes
(
d
.
hand
)
?
d
.
hand
:
"other"
)
,
interval
:
5
}
)
)
,
Plot
.
ruleY
(
[
0
]
)
]
,
color
:
{
legend
:
true
}
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Plot
.
plot
(
{
height
:
250
,
marks
:
[
Plot
.
rectY
(
population
,
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"age"
,
fill
:
(
d
)
=>
(
[
"R"
,
"L"
]
.
includes
(
d
.
hand
)
?
d
.
hand
:
"other"
)
,
interval
:
5
,
opacity
:
0
// 💡 invisible marks!
}
)
)
,
Plot
.
rectY
(
population
,
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"age"
,
filter
:
(
d
)
=>
d
.
age
>=
ageMin
&&
d
.
age
<
ageMax
,
fill
:
(
d
)
=>
(
[
"R"
,
"L"
]
.
includes
(
d
.
hand
)
?
d
.
hand
:
"other"
)
,
interval
:
5
}
)
)
,
Plot
.
ruleY
(
[
0
]
)
]
,
color
:
{
legend
:
true
}
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Plot
.
plot
(
{
height
:
250
,
marks
:
[
Plot
.
rectY
(
population
,
Plot
.
filter
(
(
[
d
]
)
=>
d
.
age
>=
ageMin
&&
d
.
age
<
ageMax
,
Plot
.
stackY
(
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"age"
,
fill
:
(
d
)
=>
(
[
"R"
,
"L"
]
.
includes
(
d
.
hand
)
?
d
.
hand
:
"other"
)
,
interval
:
5
}
)
)
)
)
,
Plot
.
ruleY
(
[
0
]
)
]
,
color
:
{
legend
:
true
}
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Plot
.
plot
(
{
height
:
250
,
marks
:
[
Plot
.
rectY
(
population
,
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"age"
,
fill
:
(
d
)
=>
(
[
"R"
,
"L"
]
.
includes
(
d
.
hand
)
?
d
.
hand
:
"other"
)
,
interval
:
5
}
)
)
,
Plot
.
rectY
(
population
,
Plot
.
binX
(
{
y
:
"count"
}
,
{
x
:
"age"
,
filter
:
(
d
)
=>
!
(
d
.
age
>=
ageMin
&&
d
.
age
<
ageMax
)
,
fill
:
"lightgray"
,
interval
:
5
}
)
)
,
Plot
.
ruleY
(
[
0
]
)
]
,
color
:
{
legend
:
true
}
}
)
Insert cell
One platform
to build and deploy the best data apps
Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
population
Show 3 comments
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
ageMin
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
ageMax
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML