code: def scale_range(vmin, vmax, n=1, threshold=100):
      dv = abs(vmax - vmin)
      if dv == 0:  # maxabsv == 0 is a special case of this.
          return 1.0, 0.0
          # Note: this should never occur because
          # vmin, vmax should have been checked by nonsingular(),
          # and spread apart if necessary.
      meanv = 0.5 * (vmax + vmin)
      if abs(meanv) / dv < threshold:
          offset = 0
      elif meanv > 0:
          ex = divmod(np.log10(meanv), 1)[0]
          offset = 10**ex
      else:
          ex = divmod(np.log10(-meanv), 1)[0]
          offset = -(10**ex)
      ex = divmod(np.log10(dv / n), 1)[0]
      scale = 10**ex
      return scale, offset
  
imports: import math
  import numpy
  from .visual import CompoundVisual, updating_property
  from .line import LineVisual
  from .text import TextVisual
label_desc: Use image node_id 1 for calling a global function with example usage: scale_range(vmin, vmax, n, threshold) and returns: scale,  offset, int,  int