Plot.plot({
x: {
domain: data2.map((d) => d.month),
padding: 0,
round: false,
axis: null
},
y: { axis: null, domain: [-0.25, 0.8], nice: true },
facet: {
data: data2,
y: "type",
marginRight: 295
},
fy: {
domain: facets,
axis: "right",
tickFormat: (d) => `${parseInt(d) < 10 ? " " : ""}${d}`,
label: null,
round: false
},
marginTop: 27,
marginLeft: 10,
marginRight: 300,
color: { domain: [false, true], range: ["white", "black"] },
marks: [
Plot.text(data2, {
filter: (d) => d.type === facets[0],
x: "month",
y: (d) => 1.5 + 0.15 * !!d.month.match(/Jan|Feb|Mar|Jul|Aug|Sep/),
text: data2.map((d) => d.month[0]),
fontSize: 13,
fontWeight: "bold"
}),
Plot.ruleY([0]),
Plot.barY(data2, {
x: "month",
y: (d) => d.count / maxes.get(d.type),
fill: (d) => d.count > means.get(d.type),
stroke: "black"
})
],
width: 580,
height: 600
})