code: def merge_figure(fig, subfig):
      
  
      # traces
      data = fig.setdefault('data', [])
      data.extend(copy.deepcopy(subfig.get('data', [])))
  
      # layout
      layout = fig.setdefault('layout', {})
      _merge_layout_objs(layout, subfig.get('layout', {}))
docs: Merge a sub-figure into a parent figure
  
      Note: This function mutates the input fig dict, but it does not mutate
      the subfig dict
  
      Parameters
      ----------
      fig: dict
          The plotly figure dict into which the sub figure will be merged
      subfig: dict
          The plotly figure dict that will be copied and then merged into `fig`