code: def plot_hierarchy(structure, iAnnotations, name):
      import pydot
  
      graph = pydot.Dot(
          graph_type="graph", rankdir="LR", fontsize="12.0"
      )
      graph.set_node_defaults(shape="record")
      lLevelsReversed = sorted(structure.keys(), reverse=True)
      for level in lLevelsReversed:
          color = "#%02x%02x%02x" % (
              255,
              255,
              127
              + int(128 * (1.0 - (level + 1.0) / len(lLevelsReversed))),
          )
          for col in structure[level].keys():
              lLabel = (
                  col
                  if iAnnotations is None
                  else str(iAnnotations[col])
              )
              if iAnnotations is not None:
                  lLabel = build_record_label(iAnnotations[col])
              node_col = pydot.Node(
                  col,
                  label=lLabel,
                  style="filled",
                  fillcolor=color,
                  fontsize="12.0",
              )
              graph.add_node(node_col)
              for col1 in structure[level][col]:
                  lLabel1 = col1
                  if iAnnotations is not None:
                      lLabel1 = build_record_label(iAnnotations[col1])
                  color1 = "#%02x%02x%02x" % (
                      255,
                      255,
                      128
                      + int(
                          128
                          * (1.0 - (level + 2.0) / len(lLevelsReversed))
                      ),
                  )
                  node_col1 = pydot.Node(
                      col1,
                      label=lLabel1,
                      style="filled",
                      fillcolor=color1,
                      fontsize="12.0",
                  )
                  graph.add_node(node_col1)
                  lEdgeLabel = ""
                  if iAnnotations is not None:
                      lEdgeLabel = iAnnotations[col + "_" + col1]
                  lEdge = pydot.Edge(
                      node_col,
                      node_col1,
                      color="red",
                      label=lEdgeLabel,
                      fontsize="12.0",
                  )
                  graph.add_edge(lEdge)
      # print(graph.obj_dict)
      if name is not None:
          graph.write_png(name)
      else:
          from IPython.display import Image, display
  
          plot1 = Image(graph.create_png())
          display(plot1)
  
file_path: atspy/atspy/TS/Plots.py
imports: import pandas
  import numpy
  from io import BytesIO
  import base64
label_desc: Use image node_id 8 for calling a global function with example usage: plot_hierarchy(structure, iAnnotations, name) without return types