code: def project_on_x(hist):
      """Project n-dim histogram onto x-axis
  
      :param hist: input histogrammar histogram
      :return: on x-axis projected histogram (1d)
      """
      # basic check: projecting on itself
      if hasattr(hist, "n_dim") and hist.n_dim <= 1:
          return hist
      # basic checks on contents
      if hasattr(hist, "bins"):
          if len(hist.bins) == 0:
              return hist
      elif hasattr(hist, "values"):
          if len(hist.values) == 0:
              return hist
      else:
          return hist
  
      # make empty clone
      # note: cannot do: h_x = hist.zero(), b/c it copies n-dim structure, which screws up hist.toJsonString()
      if isinstance(hist, histogrammar.Bin):
          h_x = histogrammar.Bin(
              num=hist.num,
              low=hist.low,
              high=hist.high,
              quantity=hist.quantity,
          )
      elif isinstance(hist, histogrammar.SparselyBin):
          h_x = histogrammar.SparselyBin(
              binWidth=hist.binWidth,
              origin=hist.origin,
              quantity=hist.quantity,
          )
      elif isinstance(hist, histogrammar.Categorize):
          h_x = histogrammar.Categorize(quantity=hist.quantity)
      else:
          raise TypeError(
              "Unknown histogram type. cannot get zero copy."
          )
  
      if hasattr(hist, "bins"):
          for key, bi in hist.bins.items():
              h_x.bins[key] = histogrammar.Count.ed(sum_entries(bi))
      elif hasattr(hist, "values"):
          for i, bi in enumerate(hist.values):
              h_x.values[i] = histogrammar.Count.ed(sum_entries(bi))
  
      return h_x
  
file_path: popmon/popmon/hist/hist_utils.py
imports: import histogrammar
  import histogrammar.specialized
  import numpy
  import pandas
  from histogrammar.specialized import CategorizeHistogramMethods, HistogramMethods, SparselyHistogramMethods, SparselyTwoDimensionallyHistogramMethods, TwoDimensionallyHistogramMethods
  from histogrammar.util import get_hist_props
label_desc: Use image node_id 2 for calling a global function with example usage: project_on_x(hist) and returns: h_x, hist, hist, hist, hist