Plot.plot({
marks: [
Plot.barX(
us_imports,
Plot.groupY(
{ x: "sum" },
{ x: "value", y: "Sector", fill: d => d.Sector === pickSector ? "purple" : bgColor, sort: { y: "x", reverse: true }}
)
),
Plot.ruleX([0]),
Plot.frame()
],
x: { tickFormat: "s", label: "Total import value ($, billions)"},
facet: { data: us_imports, x: "year" },
fx: { tickFormat: "" },
width: 900,
height: 600,
grid: true
})