code: def set_range(self, bounds, keep_aspect=False):
          
          # a * (v0 + t) = -1
          # a * (v1 + t) = +1
          # =>
          # a * (v1 - v0) = 2
          bounds = np.asarray(bounds, dtype=np.float64)
          v0 = bounds[:2]
          v1 = bounds[2:]
          pan = -.5 * (v0 + v1)
          zoom = 2. / (v1 - v0)
          if keep_aspect:
              zoom = zoom.min() * np.ones(2)
          self.set_pan_zoom(pan=pan, zoom=zoom)
docs: Zoom to fit a box.