code: def get_color_scale(plot_table, ref_group):
      """
      Calculate the color scale for the bubbles. If there are more groups than the length
      of the categorical color palette, then we use the same color for all the non-reference
      groups. Otherwise, we use an encoding where each group is given its own distinct color.
      The reference group bubble is always given the reference color.
      """
      num_groups = plot_table["attribute_value"].nunique()
      num_colors = len(Colors.CATEGORICAL_COLOR_PALETTE)
  
      if num_colors >= num_groups - 1:
          color_range = [
              Colors.REFERENCE
          ] + Colors.CATEGORICAL_COLOR_PALETTE
      else:
          # Non-reference groups are blue. We repeat the color blue per each different group
          color_range = [Colors.REFERENCE] + [
              Colors.BLUE for group in range(1, num_groups)
          ]
  
      color_domain = list(plot_table["attribute_value"])
      color_domain.insert(
          0, color_domain.pop(color_domain.index(ref_group))
      )
      color_scale = alt.Scale(domain=color_domain, range=color_range)
      return color_scale
  
file_path: aequitas/src/aequitas/plot/commons/scales.py
imports: from aequitas.plot.commons.style.classes import Shape, Bubble
  from aequitas.plot.commons.style import color
  import altair
  import math
label_desc: Use image node_id 2 for calling a global function with example usage: get_color_scale(plot_table, ref_group) and returns: color_scale