Safe Haskell  None 

Language  Haskell98 
This module contain functions for drawing diagrams of dendrograms.
Synopsis
 dendrogram :: (Monoid m, Semigroup m, Renderable (Path V2 Double) b) => Width > (a > QDiagram b V2 Double m) > Dendrogram a > QDiagram b V2 Double m
 data Width
 dendrogram' :: (Monoid m, Semigroup m, Renderable (Path V2 Double) b) => Width > (a > QDiagram b V2 Double m) > Dendrogram a > (QDiagram b V2 Double m, Dendrogram (a, X))
 dendrogramPath :: Dendrogram X > Path V2 Double
 fixedWidth :: Double > Dendrogram a > (Dendrogram (a, X), Double)
 variableWidth :: (Semigroup m, Monoid m) => (a > QDiagram b V2 Double m) > Dendrogram a > (Dendrogram (a, X), QDiagram b V2 Double m)
 type X = Double
Highlevel interface
Given a dendrogram dendro ::
and a function
Dendrogram
adrawItem :: a > Diagram b
for drawing the items on the
leaves of dendro
, just use
to draw a diagram of dendrogram
Variable
drawItem
dendro :: Diagram bdendro
.
Runnable example which produces something like https://patchtag.com/r/felipe/hierarchicalclusteringdiagrams/snapshot/current/content/pretty/example.png:
import Data.Clustering.Hierarchical (Dendrogram(..)) import Diagrams.Prelude (Diagram, atop, lw, pad, roundedRect, text, (#)) import Diagrams.Backend.Cairo.CmdLine (Cairo, defaultMain) import qualified Diagrams.Dendrogram as D main :: IO () main = defaultMain diagram diagram :: Diagram Cairo diagram = D.dendrogram
Fixed
char test # lw 0.1 # pad 1.1 char :: Char > Diagram Cairo char c = pad 1.3 $ roundedRect (1,1) 0.1 `atop` text [c] test :: Dendrogram Char test = Branch 5 (Branch 2 (Branch 1 (Leaf 'A') (Leaf 'B')) (Leaf 'C')) (Leaf 'D')
dendrogram :: (Monoid m, Semigroup m, Renderable (Path V2 Double) b) => Width > (a > QDiagram b V2 Double m) > Dendrogram a > QDiagram b V2 Double m Source #
The width of the items on the leafs of a dendrogram.
Fixed 

Variable 

dendrogram' :: (Monoid m, Semigroup m, Renderable (Path V2 Double) b) => Width > (a > QDiagram b V2 Double m) > Dendrogram a > (QDiagram b V2 Double m, Dendrogram (a, X)) Source #
Same as dendrogram
, but also returns the Dendrogram
with
positions.
Lowlevel interface
dendrogramPath :: Dendrogram X > Path V2 Double Source #
A dendrogram path that can be stroke
d
later. This function
assumes that the Leaf
s
of your Dendrogram
are already in
the right position.
fixedWidth :: Double > Dendrogram a > (Dendrogram (a, X), Double) Source #
fixedWidth w
positions the Leaf
s
of a Dendrogram
assuming that they have the same width w
. Also returns the
total width.
variableWidth :: (Semigroup m, Monoid m) => (a > QDiagram b V2 Double m) > Dendrogram a > (Dendrogram (a, X), QDiagram b V2 Double m) Source #
variableWidth draw
positions the Leaf
s
of a
Dendrogram
according to the diagram generated by draw
.
Each Leaf
may have a different width. Also returns the
resulting diagram having all Leaf
s
drawn sidebyside.
Note: you should probably use alignT
to align your items.