code: def scale_range(vmin, vmax, n=1, threshold=100):
      dv = abs(vmax - vmin)  # > 0 as nonsingular is called before.
      meanv = (vmax + vmin) / 2
      if abs(meanv) / dv < threshold:
          offset = 0
      else:
          offset = math.copysign(
              10 ** (math.log10(abs(meanv)) // 1), meanv
          )
      scale = 10 ** (math.log10(dv / n) // 1)
      return scale, offset
  
file_path: holoviews/holoviews/util/locator.py
imports: import math
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: scale_range(vmin, vmax, n, threshold) and returns: scale,  offset