#importing libraries
import altair as alt
from bokeh.sampledata.penguins import data as penguins

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)

#plotting
brush = alt.selection(type='interval')

points = alt.Chart(
  data=penguins, 
  title="Palmer Penguins Dataset",
  ).mark_circle(size=60).encode(
  alt.X('bill_length_mm', scale=alt.Scale(domain=[30,60])),
  alt.Y('bill_depth_mm', scale=alt.Scale(domain=[12,22])),
  color='species',
  ).add_selection(
    brush
)

bars = alt.Chart(penguins).mark_bar().encode(
    y='island',
    color='island',
    x='count(island)'
).transform_filter(
    brush
)

points & bars
/Users/harry/Library/Python/3.9/lib/python/site-packages/altair/utils/deprecation.py:65: AltairDeprecationWarning: 'selection' is deprecated.
   Use 'selection_point()' or 'selection_interval()' instead; these functions also include more helpful docstrings.
  warnings.warn(message, AltairDeprecationWarning, stacklevel=1)
/Users/harry/Library/Python/3.9/lib/python/site-packages/altair/utils/deprecation.py:65: AltairDeprecationWarning: 'add_selection' is deprecated. Use 'add_params' instead.
  warnings.warn(message, AltairDeprecationWarning, stacklevel=1)