pyalluv.clusters

class Cluster(height, anchor=None, width=1.0, label=None, **kwargs)[source]

Bases: object

This class defines the cluster objects for an alluvial diagram.

Note

The vertical position of a cluster will be set when creating a AlluvialPlot.

Parameters:
  • height (float, int) – The cluster size which will translate into the height of this cluster.
  • anchor (float (default=None)) – Set the anchor position. Either only the horizontal position, both \((x, y)\) or nothing can be provided.
  • width (float (default=1.0)) – Set the cluster width.
  • label (str (default=None)) – The label for this cluster, that can be shown in the diagram
  • optional parameter (**kwargs) –
    x_anchor: 'center', 'left' or 'right' (default=’center’)
    Determine where the anchor position is relative to the rectangle that will represent this cluster. Options are either the left or right corner or centered:
    linewidth: float (default=0.0)
    Set the width of the line surrounding a cluster.
    label_margin: tuple(horizontal, vertical)
    Sets horizontal and vertical margins for the label of a cluster.
x_pos

Horizontal position of the cluster anchor.

Type:float
y_pos

Vertical position of the cluster center.

Type:float
x_anchor

Anchor position relative to the rectangle representing the cluster. Possible values are: 'center', 'left' or 'right'.

Type:str
height

Size of the cluster that will determine its height in the diagram.

Type:float
width

Width of the cluster. In the same units as x_pos.

Type:float
label

Label, id or name of the cluster.

Type:str
in_fluxes

All incoming fluxes of this cluster.

Type:list[Flux]
out_fluxes

All outgoing fluxes of this cluster.

Type:list[Flux]
get_loc_in_flux(flux_width, out_loc, in_loc)[source]
get_loc_out_flux(flux_width, out_loc, in_loc)[source]
get_patch(**kwargs)[source]
set_anchor_in_fluxes()[source]
set_anchor_out_fluxes()[source]
set_in_out_anchors()[source]

This sets the proper anchor points for fluxes to enter/leave

set_loc_out_fluxes()[source]
set_mid_height(mid_height)[source]
set_x_pos(x_pos)[source]

Set the horizontal position of a cluster.

The position is set according to the value provided in x_pos and self.x_anchor.

Parameters:x_pos (float) – Horizontal position of the anchor for the cluster.
Returns:self – with new property x_pos.
Return type:Cluster
set_y_pos(y_pos)[source]
sort_in_fluxes()[source]
sort_out_fluxes()[source]