Plot.plot({
style: "overflow: visible;",
y: {grid: true, transform: (f) => Math.log10(f)},
marks: [
Plot.ruleY([0]),
Plot.lineY(d_pop, {x: "year", y: "value", stroke: "prefectures", tip: "x"}),
Plot.text(d_pop, Plot.selectLast({x: "year", y: "value", z: "prefectures", text: "prefectures", textAnchor: "start", dx: 2}))
],
caption: "日本の人口の推移(対数変換、1920~2024年)",
})
Plot.plot({
marginBottom: 60,
x: {
tickRotate: -90,
},
y: {
grid: true,
labelAnchor: "center",
},
color: {
scheme: "PiYG",
type: "ordinal"
},
marks: [
Plot.ruleY([0]),
Plot.barY(d_pinc_year, {x: "prefectures", y: "value",
fill: (d) => d.value > 0, sort: {x: "y", reverse: true}, tip: "x"})
],
caption: caption_pinc,
})
Plot.plot({
marks: [
Plot.geo(
prefectures,
{fill: (d) => d_pop_map.get(d.properties.name)}
),
Plot.tip(prefectures, Plot.pointer(Plot.geoCentroid({title: (d) => d.properties.name})))
],
caption: caption_pop,
color: {
scheme: "spectral",
unknown: "#ddd",
type: "linear",
legend: true,
label: legend_text_pop,
domain: [0, 13000],
}
})
Plot.plot({
marks: [
Plot.geo(
prefectures,
{fill: (d) => d_sex_map.get(d.properties.name)}
),
Plot.tip(prefectures, Plot.pointer(Plot.geoCentroid({title: (d) => d.properties.name})))
],
caption: caption_sex,
color: {
scheme: "spectral",
unknown: "#ddd",
type: "linear",
legend: true,
label: legend_text_sex,
domain: [0, 6500],
}
})
Plot.plot({
marks: [
Plot.geo(
prefectures,
{fill: (d) => d_pinc_map.get(d.properties.name)}
),
Plot.tip(prefectures, Plot.pointer(Plot.geoCentroid({title: (d) => d.properties.name})))
],
caption: caption_pinc,
color: {
scheme: "spectral",
unknown: "#ddd",
type: "linear",
legend: true,
label: legend_text_pinc,
}
})
d_pop = FileAttachment("d_pop_24.csv").csv({ typed: true })
d_sex = FileAttachment("d_sex_24.csv").csv({ typed: true })
d_pinc = FileAttachment("d_pinc_24.csv").csv({ typed: true })