Public
Edited
Nov 2, 2023
1 star
Insert cell
Insert cell
Plot.plot({
projection: {
type: "mercator",
domain: {
type: "MultiPoint",
coordinates: [
[58, -15], // Northwest corner (latitude, longitude)
[151, -15], // Northeast corner (latitude, longitude)
[58, 38], // Southwest corner (latitude, longitude)
[151, 38] // Southeast corner (latitude, longitude)
]
}
},
marks: [
Plot.sphere({fill: "black"}),
Plot.geo(countries, {fill: (d)=> happiness_index_sea_2022.get(d.properties.name), opacity: 1, stroke: "white",
title: (d)=> d.properties.name + "\n" + happiness_index_sea_2022.get(d.properties.name),
//filter: d=>d.properties.name == "Singapore"
}),
Plot.geo(countries, {fill: "yellow", opacity: 1, stroke: "yellow", strokeWidth: 5,
title: (d)=> d.properties.name + "\n" + happiness_index_sea_2022.get(d.properties.name),
filter: d=>d.properties.name == "Singapore"
}),
Plot.text(['Happiness index, 2022\nSoutheast Asia'],{x:120, y: 36, fontSize: 40, fill: "yellow", opacity: 1, lineHeight: 1.6, dy: -50, fontStyle: "italic", fontWeight: "Bold" }),
Plot.text(['0 (unhappy) - 10 (happy)\n\nThe average for 2022 based on 10 countries was 5.29 points.The highest value was in Singapore: 6.59 points and the lowest value was in India: 4.04 points.'],
{x:62, y: -15, fontSize: 16, fill: "yellow", opacity: 1, lineWidth: 26, textAnchor: "start", lineHeight: 1.6, clip: false }),
Plot.text(['Data: theglobaleconomy.com | Design: Deepsha Menghani | Threads: @IandLoveandData | Mastodon: @Deepsha'],{x:150, y: -29, fontSize: 14, fill: "gray", opacity: 1, textAnchor: "end", lineHeight: 1.2, clip: false, fontStyle: "italic"}),
],
width: 700,
color: {
range: myContinuousColors, // Your custom color scheme here
interpolate: "hcl" ,
legend: true, style: {fontSize: "14px"},
width: 700
}
})
Insert cell
happiness_index_sea@1.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
myContinuousColors = ["black", "yellow"]
Insert cell
happiness_index = (await FileAttachment("happiness_index_sea@1.csv").csv()).map(d => ({name: rename.get(d.country) || d.country, Year2022: +d.Year2022}))
Insert cell
happiness_index_sea_2022 = new Map(happiness_index.map(({name, Year2022}) => [name, Year2022]))
Insert cell
Insert cell
import {countries} from "ff0a83b495637684"
Insert cell
countries
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.
Learn more