class_docstr: Refer to FigureFactory.create_dendrogram() for docstring.
class_docstr_tok: ["Refer","to","FigureFactory.create_dendrogram","(",")","for","docstring","."]
code: def __init__(
      self,
      X,
      orientation="bottom",
      labels=None,
      colorscale=None,
      width=np.inf,
      height=np.inf,
      xaxis="xaxis",
      yaxis="yaxis",
      distfun=None,
      linkagefun=lambda x: sch.linkage(x, "complete"),
      hovertext=None,
      color_threshold=None,
  ):
      self.orientation = orientation
      self.labels = labels
      self.xaxis = xaxis
      self.yaxis = yaxis
      self.data = []
      self.leaves = []
      self.sign = {self.xaxis: 1, self.yaxis: 1}
      self.layout = {self.xaxis: {}, self.yaxis: {}}
  
      if self.orientation in ["left", "bottom"]:
          self.sign[self.xaxis] = 1
      else:
          self.sign[self.xaxis] = -1
  
      if self.orientation in ["right", "bottom"]:
          self.sign[self.yaxis] = 1
      else:
          self.sign[self.yaxis] = -1
  
      if distfun is None:
          distfun = scs.distance.pdist
  
      (
          dd_traces,
          xvals,
          yvals,
          ordered_labels,
          leaves,
      ) = self.get_dendrogram_traces(
          X, colorscale, distfun, linkagefun, hovertext, color_threshold
      )
  
      self.labels = ordered_labels
      self.leaves = leaves
      yvals_flat = yvals.flatten()
      xvals_flat = xvals.flatten()
  
      self.zero_vals = []
  
      for i in range(len(yvals_flat)):
          if (
              yvals_flat[i] == 0.0
              and xvals_flat[i] not in self.zero_vals
          ):
              self.zero_vals.append(xvals_flat[i])
  
      if len(self.zero_vals) > len(yvals) + 1:
          # If the length of zero_vals is larger than the length of yvals,
          # it means that there are wrong vals because of the identicial samples.
          # Three and more identicial samples will make the yvals of spliting
          # center into 0 and it will accidentally take it as leaves.
          l_border = int(min(self.zero_vals))
          r_border = int(max(self.zero_vals))
          correct_leaves_pos = range(
              l_border,
              r_border + 1,
              int((r_border - l_border) / len(yvals)),
          )
          # Regenerating the leaves pos from the self.zero_vals with equally intervals.
          self.zero_vals = [v for v in correct_leaves_pos]
  
      self.zero_vals.sort()
      self.layout = self.set_figure_layout(width, height)
      self.data = dd_traces
  
file_path: plotly.py/packages/python/plotly/plotly/figure_factory/_dendrogram.py
imports: from collections import OrderedDict
  from plotly import exceptions, optional_imports
  from plotly.graph_objs import graph_objs
label_desc: Use image node_id 1 to create a new _Dendrogram object from inherited base classes: object with example: obj = _Dendrogram(X, orientation, labels, colorscale, width, height, xaxis, yaxis, distfun, linkagefun, hovertext, color_threshold)