Hi everyone, glad to be joining this community around the wonderful Observable!
As a newcomer to Observable, I am struggling with legends. I understand how to put legends based on color or opacity from a dataset, as in many of the examples our there.
But is there a way to (manually?) build legends from the marks?
Concretely, how can I put legends on the following example (from @observablehq/plot-linear-regression):
Thanks a lot for the quick reply! The caption helps a bit, but I would really prefer a legend. I wonder if I can do it with some manual javascript trickery?
Can you describe (visually) what you want to achieve? There are lots of possibilities within Plot: you could add text (even multiline text) and other marks, or even another chart as part of the main plot… you could also create a custom mark that return a foreignObject containing any type of HTML.
You can definitely just build that legend in Plot itself. I guess the following is getting kind of close, though I’m not quite sure how to generate your outlier curves off the top of my head:
The typeset mathematics is probably the trickiest part here. You can read more about that in this and that.