Platform
Resources
Pricing
Sign in
Get started
Pablo Navarro
Mathematical engineer. Software developer at Act Now Coalition.
Workspace
Fork
Public
Course: Data Visualization Fundamentals and Best Practices
By
Pablo Navarro
Edited
Mar 9, 2023
Fork of
Lesson 2: Data Representation
Insert cell
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
dot
(
cars
,
{
x
:
"power (hp)"
,
y
:
"economy (mpg)"
}
)
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
dot
(
cars
,
{
x
:
"power (hp)"
,
y
:
"economy (mpg)"
,
r
:
"weight (lb)"
,
fill
:
"cylinders"
}
)
]
,
color
:
{
domain
:
[
3
,
4
,
6
,
8
]
,
legend
:
true
}
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
dot
(
carMakes
,
{
x
:
"power (hp)"
,
y
:
"make"
,
fill
:
"cylinders"
,
r
:
"economy (mpg)"
,
title
:
"name"
,
sort
:
{
y
:
"x"
,
reverse
:
true
}
}
)
]
,
color
:
{
domain
:
[
3
,
4
,
6
,
8
]
,
legend
:
true
}
,
marginLeft
:
100
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
dot
(
olympians
,
{
x
:
"weight"
,
y
:
"sport"
,
sort
:
{
y
:
"x"
}
}
)
]
,
y
:
{
domain
:
[
"triathlon"
,
"gymnastics"
,
"equestrian"
,
"athletics"
,
"judo"
,
"weightlifting"
]
}
,
marginLeft
:
100
,
width
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
tickX
(
olympians
,
{
x
:
"weight"
,
y
:
"sport"
,
sort
:
{
y
:
"x"
}
}
)
]
,
y
:
{
domain
:
[
"triathlon"
,
"gymnastics"
,
"equestrian"
,
"athletics"
,
"judo"
,
"weightlifting"
]
}
,
marginLeft
:
100
,
width
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
ruleY
(
[
0
]
)
,
Plot
.
lineY
(
aapl
,
{
x
:
"Date"
,
y
:
"Close"
}
)
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
ruleY
(
[
0
]
)
,
Plot
.
lineY
(
industries
,
{
x
:
"date"
,
y
:
"unemployed"
,
z
:
"industry"
,
stroke
:
"industry"
,
title
:
"industry"
}
)
]
,
color
:
{
legend
:
true
}
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
line
(
tdf
,
{
x
:
"distance"
,
y
:
"elevation"
}
)
,
// Plot.ruleY([0])
]
,
width
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
line
(
driving
,
{
x
:
"miles"
,
y
:
"gas"
,
curve
:
"catmull-rom"
,
marker
:
"circle"
}
)
,
// Plot.text(driving, {filter: d => d.year % 5 === 0, x: "miles", y: "gas", text: d => `${d.year}`, dy: -8})
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
barY
(
alphabet
,
{
x
:
"letter"
,
y
:
"frequency"
,
sort
:
{
x
:
"y"
,
reverse
:
true
}
}
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
barY
(
alphabet
,
{
x
:
"letter"
,
y
:
"frequency"
,
sort
:
{
x
:
"y"
,
reverse
:
true
}
}
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
line
(
alphabet
.
sort
(
(
a
,
b
)
=>
d3
.
ascending
(
a
.
frequency
,
b
.
frequency
)
)
,
{
x
:
"letter"
,
y
:
"frequency"
,
sort
:
{
x
:
"y"
,
reverse
:
true
}
}
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
line
(
alphabet
.
sort
(
(
a
,
b
)
=>
d3
.
ascending
(
a
.
letter
,
b
.
letter
)
)
,
{
x
:
"letter"
,
y
:
"frequency"
}
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Insert cell
laserStrikes
Filter
Columns
Sort
Slice
Save
Type Table, then Shift-Enter. Ctrl-space for more options.
Insert cell
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
barY
(
laserStrikes
,
Plot
.
groupX
(
{
y
:
"count"
}
,
{
x
:
"year"
,
fill
:
"steelblue"
}
)
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Insert cell
import
{
Plot
}
from
"@mkfreeman/plot-tooltip"
Insert cell
Insert cell
import
{
driving
}
from
"@observablehq/plot-line"
Insert cell
import
{
tdf
}
from
"@observablehq/plot-line"
Insert cell
import
{
laserStrikesCleaned
as
laserStrikes
}
from
"@observablehq/excel-add-columns"
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Compare fork
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
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
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
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
Cells
laserStrikes
File attachments
Databases
Filter
Column
Operator
Columns
Sort
Column
Direction
Descending
Ascending
Slice
From
Start
To
End
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
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
carMakes
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML