Public
Edited
Apr 2, 2024
Insert cell
Insert cell
Insert cell
Plot.plot({
caption:
"Data on prevalence is estimated from real data sources and statistical models for the region. Data from the WHO Global Health Observatory (2015).",
projection: "equal-earth",
width,
color: {
legend: true,
type: "log",
label: "Ratio of Depression Prevalence to Life Satisfaction",
scheme: "magma",
unknown: "white"
},
marks: [
Plot.geo(dataGeo, {
fill: (d) =>
d.properties["Ratio of Depression Prevalence to Life Satisfaction"],
stroke: "currentColor",
strokeWidth: 0.5
}),
Plot.sphere(),
Plot.tip(
dataGeo.features,
Plot.pointer(
Plot.centroid({
channels: {
Country: (d) => d.properties["Name"],
Ratio: (d) =>
d.properties[
"Ratio of Depression Prevalence to Life Satisfaction"
]
}
})
)
)
]
})
Insert cell
import { depressionPrevalenceProportionPerCountry2015 as gho } from "@huw/gho"
Insert cell
import { dataSnapshot as whr } from "@huw/whr"
Insert cell
import { countries110m as countries } from "@visionscarto/geo"
Insert cell
import { fixCode, codeToName } from "@huw/iso-3166-1"
Insert cell
data = aq
.from(whr)
.select(aq.not("Year"))
.join(aq.from(gho), "Code", [
aq.all(),
{ "Proportion of Depression": (d) => d["Proportion"] }
])
.derive({
"Ratio of Depression Prevalence to Life Satisfaction": (d) =>
d["Proportion of Depression"] / d["Cantril Ladder Score"]
})
.objects()
Insert cell
data
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
dataGeo = ({
...countries,
features: countries.features.map((d1) => ({
...d1,
properties: {
...data.find((d2) => d2["Code"] === fixCode(d1.properties.a3)),
Name: codeToName[fixCode(d1.properties.a3)]
}
}))
})
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