Public
Edited
Jul 22
4 forks
Importers
Insert cell
Insert cell
character_list5.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
meta_data7.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
data = aq
.from(character)
// Select the three columns
.select("script_id", "gender", "words")
// Group By
.groupby("script_id", "gender")
// Rollup and Sum words
.rollup({ totalwords: aq.op.sum("words") })
// Group by script_id
.groupby("script_id")
// // PIVOT with key = gender and value = totalwords
.pivot("gender", "totalwords")
// DERIVE
.derive({ gRatio: (d) => d.f / (d.f + d.m) })
// DERIVE
.derive({ gRatio2: (d) => aq.op.round(d.gRatio * 100) / 100 })
// GROUP BY gRatio2
.groupby("gRatio2")
// DERIVE a column with rank within the group
.derive({ rRank: aq.op.rank() })
Insert cell
Inputs.table(data)
Insert cell
Insert cell
dialogue - final.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
theChart = Plot.plot({
width: width,
color: {
type: "sequential",
domain: [0, 0.5, 1],
range: ["blue", "white", "red"]
},
marks: [
Plot.circle(dialogueFinal, {
x: "gender split",
y: "rank",
fill: "gender split",
sort: { x: "y", reverse: true }
}),
Plot.ruleY([0])
]
})
Insert cell
## Interaction Pattern

1. Select - Mark something interesting (e.g.On Hover show tool tip)

Insert cell
Insert cell
theChartwithTip = Plot.plot({
width: width,
color: {
type: "sequential",
domain: [0, 0.5, 1],
range: ["blue", "white", "red"]
},
marks: [
Plot.circle(dialogueFinal, {
x: "gender split",
y: "rank",
fill: "gender split",
tip: true,
sort: { x: "y", reverse: true }
}),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
Insert cell
movieNames = dialogueFinal.map((d) => d.title)
Insert cell
viewof movieHighlight = Inputs.select(movieNames, { label: "Select one" })
Insert cell
Insert cell
highlightTable = dialogueFinal.filter((d) => d.title === movieHighlight)
Insert cell
Insert cell
theChartwithHighlight = Plot.plot({
width: width,
color: {
type: "sequential",
domain: [0, 0.5, 1],
range: ["blue", "white", "red"]
},
marks: [
Plot.circle(dialogueFinal, {
x: "gender split",
y: "rank",
fill: "gender split",
sort: { x: "y", reverse: true }
}),
Plot.circle(highlightTable, {
x: "gender split",
y: "rank",
fill: "#fe34db",
r: 10,
tip: true,
sort: { x: "y", reverse: true }
}),

Plot.ruleY([0])
]
})
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.
Learn more