code: def scale_and_shift(self, scale_pct, shift_pct, callback=True):
          
          maxlen = self.maxc + 1
          self.sarr = np.arange(maxlen)
  
          # limit shrinkage to 5% of original size
          scale = max(scale_pct, 0.050)
          self.scale_pct = scale
  
          work = self._stretch(self.sarr, scale)
          n = len(work)
          if n < maxlen:
              # pad on the lowest and highest values of the shift map
              m = (maxlen - n) // 2 + 1
              barr = np.array([0] * m)
              tarr = np.array([self.maxc] * m)
              work = np.concatenate([barr, work, tarr])
              work = work[:maxlen]
  
          # we are mimicing ds9's stretch and shift algorithm here.
          # ds9 seems to cut the center out of the stretched array
          # BEFORE shifting
          n = len(work) // 2
          halflen = maxlen // 2
          work = work[n - halflen:n + halflen].astype(np.uint, copy=False)
          assert len(work) == maxlen, \
              RGBMapError("scaled shift map is != %d" % maxlen)
  
          # shift map according to the shift_pct
          work = self._shift(work, shift_pct)
          assert len(work) == maxlen, \
              RGBMapError("shifted shift map is != %d" % maxlen)
  
          self.t_.set(shift_array=work)
docs: Stretch and/or shrink the color map via altering the shift map.