class_docstr: Dodge overlaps and place objects side-by-side
  
  Parameters
  ----------
  width :
      Dodging width, when different to the width of the
      individual elements. This is useful when you want
      to align narrow geoms with wider geoms
  preserve :
      Should dodging preserve the total width of all elements
      at a position, or the width of a single element?
docstr: Dodge overlapping interval
  
  Assumes that each set has the same horizontal position.
docstr_tok: ["Dodge","overlapping","interval","Assumes","that","each","set","has","the","same","horizontal","position","."]
code: def strategy(data, params):
      """
      Dodge overlapping interval
  
      Assumes that each set has the same horizontal position.
      """
      width = params["width"]
      with suppress(TypeError):
          iter(width)
          width = np.asarray(width)
          width = width[data.index]
  
      udata_group = data["group"].drop_duplicates()
  
      n = params.get("n", None)
      if n is None:
          n = len(udata_group)
      if n == 1:
          return data
  
      if not all(col in data.columns for col in ["xmin", "xmax"]):
          data["xmin"] = data["x"]
          data["xmax"] = data["x"]
  
      d_width = np.max(data["xmax"] - data["xmin"])
  
      # Have a new group index from 1 to number of groups.
      # This might be needed if the group numbers in this set don't
      # include all of 1:n
      udata_group = udata_group.sort_values()
      groupidx = match(data["group"], udata_group)
      groupidx = np.asarray(groupidx) + 1
  
      # Find the center for each group, then use that to
      # calculate xmin and xmax
      data["x"] = data["x"] + width * ((groupidx - 0.5) / n - 0.5)
      data["xmin"] = data["x"] - (d_width / n) / 2
      data["xmax"] = data["x"] + (d_width / n) / 2
  
      if "x" in data and "xend" in data:
          data["x"] = data["xmin"]
          data["xend"] = data["xmax"]
  
      return data
  
file_path: plotnine/plotnine/positions/position_dodge.py
imports: from __future__ import annotations
  import typing
  from contextlib import suppress
  from copy import copy
  import numpy
  import pandas
  from .._utils import groupby_apply, match
  from ..exceptions import PlotnineError
  from .position import position
label_desc: Use image node_id 5 for calling the position_dodge obj's underlying member method code with example usage: obj.strategy(data, params) and returns: data, data