title: How to update histogram based on selection of points (Altair)?
body: <p>My goal is to update the histogram shown on the right side of <a href="https://i.stack.imgur.com/ydbT3.jpg" rel="nofollow noreferrer">1</a> based on the selection of points on the left side.
  Initially the plot seems to be alright, however once a selection is made the histogram won't be redrawn (altair 3.2.0)</p>
  
  <p>Does anybody know how to do this?</p>
  
  <p><a href="https://i.stack.imgur.com/ydbT3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ydbT3.jpg" alt="hist should be updated upon selection of the points on the left"></a></p>
  
  <p>below is the code to recreate the example:</p>
  
  <pre><code>import altair as alt
  import pandas as pd
  import numpy as np
  from random import choice
  
  dates = pd.date_range("1.1.2019", "2.28.2019")
  np.random.seed(999)
  Y = np.random.normal(0.5, 0.1, len(dates))
  features = [choice(["a", "b", "c"]) for i in range(len(dates))]
  df = pd.DataFrame({"dates": dates, "Y": Y, "features": features})
  
  base = alt.Chart(df)
  area_args = {"opacity": 0.3, "interpolate": "step"}
  pts = alt.selection(type="interval", encodings=["x"])
  points = (
      base.mark_circle()
      .encode(alt.X("dates:T"), alt.Y("Y:Q"), color="features:N")
      .add_selection(pts)
  )
  
  yscale = alt.Scale(domain=(0, 1))
  right_hist = (
      base.mark_area(**area_args)
      .encode(
          alt.Y(
              "Y:Q", bin=alt.Bin(maxbins=20, extent=yscale.domain), stack=None, title=""
          ),
          alt.X("count()", stack=None, title=""),
          alt.Color("features:N"),
      )
      .transform_filter(pts)
  )
  
  (points | right_hist)
  </code></pre>
  
  <p><em>edit1</em>: another image to clarify my point @jvp</p>
  
  <p><a href="https://i.stack.imgur.com/RSSAr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RSSAr.jpg" alt="enter image description here"></a></p>