code: def update_rect(
      rect, ax
  ):  # Let the rectangle track the bounds of the zoom axes.
      xlo, xhi = ax.get_xlim()
      ylo, yhi = ax.get_ylim()
      rect.set_bounds((xlo, ylo, xhi - xlo, yhi - ylo))
      ax.figure.canvas.draw_idle()
  
file_path: matplotlib/galleries/examples/event_handling/viewlims.py
imports: import functools
  import matplotlib.pyplot
  import numpy
  from matplotlib.patches import Rectangle
label_desc: Use image node_id 1 for calling a global function with example usage: update_rect(rect, ax) without return types