prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Interval Selection Example Bug
  I am having trouble with the the [Interval Selection Example](https://altair-viz.github.io/gallery/interval_selection.html). 
  ![interval-selection](https://user-images.githubusercontent.com/2041969/72012337-c813a500-3229-11ea-911c-d130c87ce01e.gif)
  
  ```python
  import altair as alt
  from vega_datasets import data
  
  source = data.sp500.url
  
  brush = alt.selection(type='interval', encodings=['x'])
  
  upper = alt.Chart(source).mark_area().encode(
      alt.X('date:T', scale=alt.Scale(domain=brush)),
      y='price:Q'
  ).properties(
      width=600,
      height=200
  )
  
  lower = upper.properties(
      height=60
  ).add_selection(brush)
  
  upper & lower
  ```
  
  The example looks correct so I am unsure what is causing this behavior. 
  
  </issue>
  <code>
  [start of altair/examples/interval_selection.py]
  1 """
  2 Interval Selection Example
  3 ==========================
  4 
  5 This is an example of creating a stacked chart for which the domain of the
  6 top chart can be selected by interacting with the bottom chart.
  7 """
  8 # category: area charts
  9 import altair as alt
  10 from vega_datasets import data
  11 
  12 source = data.sp500.url
  13 
  14 brush = alt.selection(type='interval', encodings=['x'])
  15 
  16 upper = alt.Chart(source).mark_area().encode(
  17     alt.X('date:T', scale=alt.Scale(domain=brush)),
  18     y='price:Q'
  19 ).properties(
  20     width=600,
  21     height=200
  22 )
  23 
  24 lower = upper.properties(
  25     height=60
  26 ).add_selection(brush)
  27 
  28 upper & lower
  29
  [end of altair/examples/interval_selection.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/altair/examples/interval_selection.py b/altair/examples/interval_selection.py
  --- a/altair/examples/interval_selection.py
  +++ b/altair/examples/interval_selection.py
  @@ -13,15 +13,19 @@
   
   brush = alt.selection(type='interval', encodings=['x'])
   
  -upper = alt.Chart(source).mark_area().encode(
  -    alt.X('date:T', scale=alt.Scale(domain=brush)),
  -    y='price:Q'
  +base = alt.Chart(source).mark_area().encode(
  +    x = 'date:T',
  +    y = 'price:Q'
   ).properties(
       width=600,
       height=200
   )
   
  -lower = upper.properties(
  +upper = base.encode(
  +    alt.X('date:T', scale=alt.Scale(domain=brush))
  +)
  +
  +lower = base.properties(
       height=60
   ).add_selection(brush)
  
verification_info: {"golden_diff": "diff --git a/altair/examples/interval_selection.py b/altair/examples/interval_selection.py\n--- a/altair/examples/interval_selection.py\n+++ b/altair/examples/interval_selection.py\n@@ -13,15 +13,19 @@\n \n brush = alt.selection(type='interval', encodings=['x'])\n \n-upper = alt.Chart(source).mark_area().encode(\n-    alt.X('date:T', scale=alt.Scale(domain=brush)),\n-    y='price:Q'\n+base = alt.Chart(source).mark_area().encode(\n+    x = 'date:T',\n+    y = 'price:Q'\n ).properties(\n     width=600,\n     height=200\n )\n \n-lower = upper.properties(\n+upper = base.encode(\n+    alt.X('date:T', scale=alt.Scale(domain=brush))\n+)\n+\n+lower = base.properties(\n     height=60\n ).add_selection(brush)\n", "issue": "Interval Selection Example Bug\nI am having trouble with the the [Interval Selection Example](https://altair-viz.github.io/gallery/interval_selection.html). \r\n![interval-selection](https://user-images.githubusercontent.com/2041969/72012337-c813a500-3229-11ea-911c-d130c87ce01e.gif)\r\n\r\n```python\r\nimport altair as alt\r\nfrom vega_datasets import data\r\n\r\nsource = data.sp500.url\r\n\r\nbrush = alt.selection(type='interval', encodings=['x'])\r\n\r\nupper = alt.Chart(source).mark_area().encode(\r\n    alt.X('date:T', scale=alt.Scale(domain=brush)),\r\n    y='price:Q'\r\n).properties(\r\n    width=600,\r\n    height=200\r\n)\r\n\r\nlower = upper.properties(\r\n    height=60\r\n).add_selection(brush)\r\n\r\nupper & lower\r\n```\r\n\r\nThe example looks correct so I am unsure what is causing this behavior. \n", "before_files": [{"content": "\"\"\"\nInterval Selection Example\n==========================\n\nThis is an example of creating a stacked chart for which the domain of the\ntop chart can be selected by interacting with the bottom chart.\n\"\"\"\n# category: area charts\nimport altair as alt\nfrom vega_datasets import data\n\nsource = data.sp500.url\n\nbrush = alt.selection(type='interval', encodings=['x'])\n\nupper = alt.Chart(source).mark_area().encode(\n    alt.X('date:T', scale=alt.Scale(domain=brush)),\n    y='price:Q'\n).properties(\n    width=600,\n    height=200\n)\n\nlower = upper.properties(\n    height=60\n).add_selection(brush)\n\nupper & lower\n", "path": "altair/examples/interval_selection.py"}]}