Histogram with average line

Trying to understand abilities of groups and bins. Is there a way to add an average line to a histogram in Plot using Plot functions? I can make a ruleX mark where I find the average and pass that as data, but wondering if group transforms can get me to the same place.

Plot.plot({
  marks: [
    Plot.rectY(olympians, Plot.binX({y: "count"}, {x: "weight", thresholds})),
    // alter the data, can this be done passing olympians and using groups/bins in Plot?
    Plot.ruleX([d3.mean(olympians.map(d => d.weight))], {stroke: "red"}),
    Plot.ruleY([0])
  ]
})

Always learning,
Zach

Yes:

Plot.ruleX(olympians, Plot.groupZ({ x: "mean" }, { x: "weight", stroke: "red" })),
1 Like

Yes, that! Thanks!