code: def plot_weights_given_ax(
      ax,
      array,
      height_padding_factor,
      length_padding,
      subticks_frequency,
      highlight,
      colors=default_colors,
      plot_funcs=default_plot_funcs,
  ):
      if len(array.shape) == 3:
          array = np.squeeze(array)
      assert len(array.shape) == 2, array.shape
      if array.shape[0] == 4 and array.shape[1] != 4:
          array = array.transpose(1, 0)
      assert array.shape[1] == 4
      max_pos_height = 0.0
      min_neg_height = 0.0
      heights_at_positions = []
      depths_at_positions = []
      for i in range(array.shape[0]):
          # sort from smallest to highest magnitude
          acgt_vals = sorted(
              enumerate(array[i, :]), key=lambda x: abs(x[1])
          )
          positive_height_so_far = 0.0
          negative_height_so_far = 0.0
          for letter in acgt_vals:
              plot_func = plot_funcs[letter[0]]
              color = colors[letter[0]]
              if letter[1] > 0:
                  height_so_far = positive_height_so_far
                  positive_height_so_far += letter[1]
              else:
                  height_so_far = negative_height_so_far
                  negative_height_so_far += letter[1]
              plot_func(
                  ax=ax,
                  base=height_so_far,
                  left_edge=i,
                  height=letter[1],
                  color=color,
              )
          max_pos_height = max(max_pos_height, positive_height_so_far)
          min_neg_height = min(min_neg_height, negative_height_so_far)
          heights_at_positions.append(positive_height_so_far)
          depths_at_positions.append(negative_height_so_far)
  
      # now highlight any desired positions; the key of
      # the highlight dict should be the color
      for color in highlight:
          for start_pos, end_pos in highlight[color]:
              assert start_pos >= 0.0 and end_pos <= array.shape[0]
              min_depth = np.min(depths_at_positions[start_pos:end_pos])
              max_height = np.max(
                  heights_at_positions[start_pos:end_pos]
              )
              ax.add_patch(
                  matplotlib.patches.Rectangle(
                      xy=[start_pos, min_depth],
                      width=end_pos - start_pos,
                      height=max_height - min_depth,
                      edgecolor=color,
                      fill=False,
                  )
              )
  
      ax.set_xlim(-length_padding, array.shape[0] + length_padding)
      ax.xaxis.set_ticks(
          np.arange(0.0, array.shape[0] + 1, subticks_frequency)
      )
      height_padding = max(
          abs(min_neg_height) * (height_padding_factor),
          abs(max_pos_height) * (height_padding_factor),
      )
      ax.set_ylim(
          min_neg_height - height_padding,
          max_pos_height + height_padding,
      )
  
file_path: deeplift/deeplift/visualization/viz_sequence.py
imports: import matplotlib
  import matplotlib.pyplot
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: plot_weights_given_ax(ax, array, height_padding_factor, length_padding, subticks_frequency, highlight, colors, plot_funcs) without return types