code: def onselect(xmin, xmax):
      indmin, indmax = np.searchsorted(x, (xmin, xmax))
      indmax = min(len(x) - 1, indmax)
  
      region_x = x[indmin:indmax]
      region_y = y[indmin:indmax]
  
      if len(region_x) >= 2:
          line2.set_data(region_x, region_y)
          ax2.set_xlim(region_x[0], region_x[-1])
          ax2.set_ylim(region_y.min(), region_y.max())
          fig.canvas.draw_idle()
  
imports: import matplotlib.pyplot
  import numpy
  from matplotlib.widgets import SpanSelector
label_desc: Use image node_id 1 for calling a global function with example usage: onselect(xmin, xmax) without return types