code: def read_colorscale(cmap_file):
      
      assert isinstance(cmap_file, str)
  
      cm = np.loadtxt(cmap_file, delimiter='\t', dtype=np.float64)
      # x = cm[:, 0]
      rgb = np.int64(cm[:, 1:])  # normalize to 0-1?
      n = cm.shape[0]
      colorscale = []
      for i in range(n):
          colorscale.append(
              [i / float(n - 1),
               'rgb(%d, %d, %d)' % (rgb[i, 0], rgb[i, 1], rgb[i, 2])]
          )
      return colorscale
docs: Return a colorscale in the format expected by plotly.
  
      Parameters
      ----------
      cmap_file : str
          Path of a plain-text file containing the colorscale. 
  
      Returns
      -------
      list
          The colorscale.
          
      Notes
      -----
      A plotly colorscale is a list where each item is a pair
      (i.e., a list with two elements) consisting of
      a decimal number x between 0 and 1 and a corresponding "rgb(r,g,b)" string,
      where r, g, and b are integers between 0 and 255.
  
      The `cmap_file` is a tab-separated text file containing four columns
      (x,r,g,b), so that each row corresponds to an entry in the list
      described above.