Plot.plot({
marginLeft: 70,
marginRight: 50,
y: { domain: [0, 6500] },
marks: [
Plot.line(data.filter(function(d) {return d.sex != null}),
Plot.groupX({ y: "mean" }, { y: "body_mass", x: "species", stroke: "sex", strokeOpacity: 0.5 })
),
Plot.link(data.filter(function(d) {return d.sex != null}),
Plot.groupX(
{
y1: (data) => d3.mean(data) - d3.deviation(data),
y2: (data) => d3.mean(data) + d3.deviation(data)
},
{
y: "body_mass",
x: "species",
stroke: "sex",
strokeOpacity: 0.5,
strokeWidth: 3 ,
title: (d) => `${d.sex}`
}
)
)
]
})