plot1 = Plot.plot({
y: {
grid: true,
label: "Average CO2 usage per passenger (kg)",
domain: [0, 340]
},
width: 700,
height: 500,
x: {
label: "Route",
axis: null
},
color: {
domain: ["plane", "train"],
range: ["grey", "#37a633"],
legend: true
},
marks: [
Plot.barY(avg_co2_df,
{x: d => d["Route"] + " " + d["Mode"],
y1: 0,
y2: "avg_co2",
fill: d => d["Mode"] == "Train" ? "train" : "plane"
}),
Plot.text(avg_co2_df,{
x: d => d["Route"] + " " + d["Mode"],
y: "avg_co2",
text: d => d["Route"].split("-")[0] + " to \n" + d["Route"].split("-")[1],
fontSize: 10,
dy: -25,
fill: "black",
})
]
})