Athletes (Regression)
Use the drop downs to filter by sport or sex. Select a range on the plot to filter the table and see the regression lines for the selected range. Hover over the table to highlight the corresponding point on the plot.
Use the drop downs to filter by sport or sex. Select a range on the plot to filter the table and see the regression lines for the selected range. Hover over the table to highlight the corresponding point on the plot.
---
title: "Athletes (Regression)"
---
Use the drop downs to filter by sport or sex. Select a range on the plot to filter the table and see the regression lines for the selected range. Hover over the table to highlight the corresponding point on the plot.
```{python}
from inspect_viz import Data, Selection
from inspect_viz.input import search, select
from inspect_viz.interactor import Brush, interval_xy
from inspect_viz.layout import hconcat
from inspect_viz.mark import dot, regression_y
from inspect_viz.plot import plot
from inspect_viz.table import column, table
athletes = Data.from_file("athletes.parquet")
category = Selection.intersect()
query = Selection.intersect(include=category)
hover = Selection.intersect(empty=True)
```
```{python}
hconcat(
select(athletes, label="Sport", column="sport", target=category),
select(athletes, label="Sex", column="sex", target=category),
)
```
```{python}
plot(
dot(
athletes,
filter_by=query,
x="weight",
y="height",
fill="sex",
r=2,
opacity=0.1,
),
regression_y(athletes, filter_by=query, x="weight", y="height", stroke="sex"),
interval_xy(target=query, brush=Brush(fill_opacity=0, stroke="black")),
dot(
athletes,
filter_by=hover,
x="weight",
y="height",
fill="sex",
stroke="currentColor",
stroke_width=1,
r=3
),
xy_domain="fixed",
r_domain="fixed",
color_domain="fixed"
)
```
```{python}
table(
athletes,
filter_by=query,
target=hover,
columns=[
column("name", width=200),
"sex",
"height",
"weight",
"sport"
],
)
```