rdkit.ML.Cluster.ClusterVis module — The RDKit 2025.09.6 documentation

# rdkit.ML.Cluster.ClusterVis module

Cluster tree visualization using Sping

class rdkit.ML.Cluster.ClusterVis.ClusterRenderer(canvas, size, ptColors=[], lineWidth=None, showIndices=0, showNodes=1, stopAtCentroids=0, logScale=0, tooClose=-1)

  Bases: `object`

  DrawTree(cluster, minHeight=2.0)

rdkit.ML.Cluster.ClusterVis.ClusterToImg(cluster, fileName, size=(300, 300), ptColors=[], lineWidth=None, showIndices=0, stopAtCentroids=0, logScale=0)

  handles the work of drawing a cluster tree to an image file

  > Arguments

  > > - cluster: the cluster tree to be drawn

  > > - fileName: the name of the file to be created

  > > - size: the size of output canvas

  > > - ptColors: if this is specified, the _colors_ will be used to color the terminal nodes of the cluster tree. (color == _pid.Color_)

  > > - lineWidth: if specified, it will be used for the widths of the lines used to draw the tree

  Notes

  > - The extension on _fileName_ determines the type of image file created. All formats supported by PIL can be used.

  > - if _ptColors_ is the wrong length for the number of possible terminal node types, this will throw an IndexError

  > - terminal node types are determined using their _GetData()_ methods

rdkit.ML.Cluster.ClusterVis.ClusterToPDF(cluster, fileName, size=(300, 300), ptColors=[], lineWidth=None, showIndices=0, stopAtCentroids=0, logScale=0)

  handles the work of drawing a cluster tree to an PDF file

  > Arguments

  > > - cluster: the cluster tree to be drawn

  > > - fileName: the name of the file to be created

  > > - size: the size of output canvas

  > > - ptColors: if this is specified, the _colors_ will be used to color the terminal nodes of the cluster tree. (color == _pid.Color_)

  > > - lineWidth: if specified, it will be used for the widths of the lines used to draw the tree

  Notes

  > - if _ptColors_ is the wrong length for the number of possible terminal node types, this will throw an IndexError

  > - terminal node types are determined using their _GetData()_ methods

rdkit.ML.Cluster.ClusterVis.ClusterToSVG(cluster, fileName, size=(300, 300), ptColors=[], lineWidth=None, showIndices=0, stopAtCentroids=0, logScale=0)

  handles the work of drawing a cluster tree to an SVG file

  > Arguments

  > > - cluster: the cluster tree to be drawn

  > > - fileName: the name of the file to be created

  > > - size: the size of output canvas

  > > - ptColors: if this is specified, the _colors_ will be used to color the terminal nodes of the cluster tree. (color == _pid.Color_)

  > > - lineWidth: if specified, it will be used for the widths of the lines used to draw the tree

  Notes

  > - if _ptColors_ is the wrong length for the number of possible terminal node types, this will throw an IndexError

  > - terminal node types are determined using their _GetData()_ methods

rdkit.ML.Cluster.ClusterVis.DrawClusterTree(cluster, canvas, size, ptColors=[], lineWidth=None, showIndices=0, showNodes=1, stopAtCentroids=0, logScale=0, tooClose=-1)

  handles the work of drawing a cluster tree on a Sping canvas

  > Arguments

  > > - cluster: the cluster tree to be drawn

  > > - canvas: the Sping canvas on which to draw

  > > - size: the size of _canvas_

  > > - ptColors: if this is specified, the _colors_ will be used to color the terminal nodes of the cluster tree. (color == _pid.Color_)

  > > - lineWidth: if specified, it will be used for the widths of the lines used to draw the tree

  Notes

  > - _Canvas_ is neither _save_d nor _flush_ed at the end of this

  > - if _ptColors_ is the wrong length for the number of possible terminal node types, this will throw an IndexError

  > - terminal node types are determined using their _GetData()_ methods

class rdkit.ML.Cluster.ClusterVis.VisOpts

  Bases: `object`

  stores visualization options for cluster viewing

  Instance variables

  > - x/yOffset: amount by which the drawing is offset from the edges of the canvas

  > - lineColor: default color for drawing the cluster tree

  > - lineWidth: the width of the lines used to draw the tree

  hideColor = Color(0.80,0.80,0.80)
  hideWidth = 1.1
  highlightColor = Color(1.00,1.00,0.40)
  highlightRad = 10
  lineColor = Color(0.00,0.00,0.00)
  lineWidth = 2
  nodeColor = Color(1.00,0.40,0.40)
  nodeRad = 15
  terminalColors = [Color(1.00,0.00,0.00), Color(0.00,0.00,1.00), Color(1.00,1.00,0.00), Color(0.00,0.50,0.50), Color(0.00,0.80,0.00), Color(0.50,0.50,0.50), Color(0.80,0.30,0.30), Color(0.30,0.30,0.80), Color(0.80,0.80,0.30), Color(0.30,0.80,0.80)]
  xOffset = 20
  yOffset = 20