Grouped regression

Regression lines grouped by a categorical variable, with different colors for each group. Based on an example from Observable Plot.

<Plot grid height={500} color={{ legend: true }}>
    <Dot
        data={penguins}
        x="culmen_length_mm"
        y="culmen_depth_mm"
        fill="species" />
    <RegressionY
        data={penguins}
        x="culmen_length_mm"
        y="culmen_depth_mm" />
    <RegressionY
        data={penguins}
        x="culmen_length_mm"
        y="culmen_depth_mm"
        stroke="species" />
</Plot>
Improve this page
Last update at: 2025/11/24