plot_other_industry_co2_2 = Plot.plot({
title: "CO2 emissions per year - " + [grafic2],
subtitle: "from 1980 to 2020",
width: 1100,
height: 500,
marginRight: 120,
marginBottom: 60,
x: {grid: true, label: "Year", labelAnchor: "center", labelArrow: false, labelOffset: 35},
y: {grid: true, label: grafic2, labelAnchor: "center", labelArrow: false, labelOffset: 40},
color:{
type: "categorical",
legend: true,
domain: ["Italy", "Spain"],
range: ["green", "red"],
},
marks: [
Plot.ruleY([0]),
Plot.lineY(dadesfiltrades, {
x: "year",
y: grafic2,
z: "country",
color: { legend: "country"},
stroke: "country"
}),
Plot.text(dadesfiltrades, Plot.selectLast({x: "year", y: grafic2, z: "country", text: "country", textAnchor: "start", dx: 3})),
Plot.text(dadesfiltrades, {filter: (d) => d.year % 5 === 0, x: "year", y: grafic2, text: (d) => `${d[grafic2]}`, dy: -12}),
Plot.circle(dadesfiltrades, { x: "year", y: grafic2, fill: "country" }),
]
});