class_docstr: Area is a Chart element representing the area under a curve or
  between two curves in a 1D coordinate system. The key dimension
  represents the location of each coordinate along the x-axis, while
  the value dimension(s) represent the height of the area or the
  lower and upper bounds of the area between curves.
  
  Multiple areas may be stacked by overlaying them an passing them
  to the stack method.
docstr: Stacks an (Nd)Overlay of Area or Curve Elements by offsetting
  their baselines. To stack a HoloMap or DynamicMap use the map
  method.
docstr_tok: ["Stacks","an","(","Nd",")","Overlay","of","Area","or","Curve","Elements","by","offsetting","their","baselines",".","To","stack","a","HoloMap","or","DynamicMap","use","the","map","method","."]
code: def stack(cls, areas, baseline_name="Baseline"):
      """
      Stacks an (Nd)Overlay of Area or Curve Elements by offsetting
      their baselines. To stack a HoloMap or DynamicMap use the map
      method.
      """
      if not len(areas):
          return areas
      is_overlay = isinstance(areas, Overlay)
      if is_overlay:
          areas = NdOverlay({i: el for i, el in enumerate(areas)})
      df = areas.dframe(multi_index=True)
      levels = list(range(areas.ndims))
      vdims = [[el.vdims[0], baseline_name] for el in areas]
      baseline = None
      stacked = areas.clone(shared_data=False)
      if len(levels) == 1:
          # Pandas 2.1 gives the following FutureWarning:
          #   Creating a Groupby object with a length-1 list-like level parameter
          #   will yield indexes as tuples in a future version.
          levels = levels[0]
      for (key, sdf), element_vdims in zip(
          df.groupby(level=levels, sort=False), vdims
      ):
          vdim = element_vdims[0]
          sdf = sdf.droplevel(levels).reindex(
              index=df.index.unique(-1), fill_value=0
          )
          if baseline is None:
              sdf[baseline_name] = 0
          else:
              sdf[vdim.name] = sdf[vdim.name] + baseline
              sdf[baseline_name] = baseline
          baseline = sdf[vdim.name]
          stacked[key] = areas[key].clone(sdf, vdims=element_vdims)
      return Overlay(stacked.values()) if is_overlay else stacked
  
imports: import numpy
  import param
  from ..core import Dataset, Dimension, Element2D, NdOverlay, Overlay, util
  from ..core.dimension import process_dimensions
  from .geom import Points, Rectangles, VectorField
  from .selection import Selection1DExpr
label_desc: Use image node_id 1 for calling the Area obj's underlying member method code with example usage: obj.stack(cls, areas, baseline_name) and returns: unknown, areas