code: def color_array_by_hue_mix(value, palette):
      
      if int(value, 2) > 0:
  
          # Convert bits to list and reverse order to avoid issues with
          # differing lengths
          int_list = [int(i) for i in list(value[2:])]
          int_list.reverse()
  
          # since this is a 1D array, we need the zeroth elements
          # of np.nonzero.
          locs = np.nonzero(int_list)[0]
          # print(locs)
          # print(palette)
          rgb_vals = [palette[i] for i in locs]
  
          rgb = [0]*len(rgb_vals[0])  # We don't know if it's rgb or rgba
          for val in rgb_vals:
              for index in range(len(val)):
                  rgb[index] += val[index]
  
          for i in range(len(rgb)):
              rgb[i] /= len(locs)
  
          return tuple(rgb)
  
      if int(value, 2) == 0:
          return (1, 1, 1) if len(palette[0]) == 3 else (1, 1, 1, 1)
  
      return -1
docs: Figure out the appropriate color for a binary string value by averaging
      the colors corresponding the indices of each one that it contains. Makes
      for visualizations that intuitively show patch overlap.