This message was deleted.
# help
s
This message was deleted.
a
Hi Dylan! Here’s an option to add a horizontal line at the median:
Copy code
Plot.plot({
  marks: [
    Plot.dot(penguins, { x: "flipper_length_mm", y: "body_mass_g" }),
    Plot.ruleY([d3.median(penguins, (d) => d.body_mass_g)])
  ]
})
So with your data, I think that Plot.ruleY line would be:
Plot.ruleY([d3.median(data, d => d.a8_avg)])
Does that work?
💥 1
🙌 1
(also I hope you feel better soon! 🍵)
👍 1
d
@Allison (Observable Team) thank you so much! Now that's out of the way I'm feeling a bit better 🙂
@Allison (Observable Team) I don't know if this is relevant to the Observable team but I've found that ChatGPT is really not much help at all for working in Observable. For D3 itself it's ok (still not perfect) but answers tend not to take into account the 'cellular' nature of Observable, or use the Plot library. At least in my experience. I don't suppose there's much you can do about that though.
m
No, not really. We can't control what OpenAI releases or uses as training material. It's kind of like someone published a book with a bunch of wrong info about how to write notebooks
👍 1
m
I recommend the groupZ transform. To take Allison’s example:
Copy code
Plot.plot({
  marks: [
    Plot.dot(penguins, {x: "flipper_length_mm", y: "body_mass_g"}),
    Plot.ruleY(penguins, Plot.groupZ({y: "median"}, {y: "body_mass_g"}))
  ]
})
You can use d3.median too, but groupZ is nice because it’ll work with faceting etc.
🌟 1
🎉 1
a
oh way better, thanks Mike!
❤️ 1
d
Wow, thanks @Mike Bostock! That's such a tidy way to do it.
🙏 1