Skip to content

ragraph.plot

RaGraph plotting module

Style

Style(
    boxsize: Optional[int] = None,
    config: Optional[Dict[str, Any]] = None,
    highlight_annotation: Optional[str] = None,
    highlight_color: Optional[str] = None,
    labels: Optional[
        Union[LabelsStyle, Dict[str, Any]]
    ] = None,
    layout: Optional[
        Union[go.Layout, Dict[str, Any]]
    ] = None,
    palettes: Optional[Palettes] = None,
    piemap: Optional[
        Union[PieMapStyle, Dict[str, Any]]
    ] = None,
    tree: Optional[Union[TreeStyle, Dict[str, Any]]] = None,
    legend: Optional[
        Union[LegendStyle, Dict[str, Any]]
    ] = None,
    show_legend: Optional[bool] = None,
    row_col_numbers: Optional[bool] = None,
    xstep: Optional[str] = None,
    ystep: Optional[str] = None,
)

Bases: Mapping

RaGraph plot style mapping.

Parameters:

Name Type Description Default
boxsize Optional[int]

Size in pixels per row or column.

None
config Optional[Dict[str, Any]]

Plotly Figure.show() config.

None
highlight_annotation Optional[str]

Annotation key of instances that should be highlighted. Value should be True-ish. Set key to None to disable.

None
highlight_color Optional[str]

Default color to use for highlights.

None
labels Optional[Union[LabelsStyle, Dict[str, Any]]]

Labels plot style.

None
layout Optional[Union[Layout, Dict[str, Any]]]

Layout options.

None
palettes Optional[Palettes]

Plot palettes options.

None
piemap Optional[Union[PieMapStyle, Dict[str, Any]]]

Piechart map plot style.

None
tree Optional[Union[TreeStyle, Dict[str, Any]]]

Tree plot style.

None
legend Optional[Union[LegendStyle, Dict[str, Any]]]

Legend plot style.

None
show_legend Optional[bool]

Bool to display legend.

None
row_col_numbers Optional[bool]

Bool to display row and column numbers.

None
xstep Optional[str]

Axis increment per row or column in plots (usually 1).

None
ystep Optional[str]

Axis increment per row or column in plots (usually 1).

None
Source code in ragraph/plot/generic.py
def __init__(
    self,
    boxsize: Optional[int] = None,
    config: Optional[Dict[str, Any]] = None,
    highlight_annotation: Optional[str] = None,
    highlight_color: Optional[str] = None,
    labels: Optional[Union[LabelsStyle, Dict[str, Any]]] = None,
    layout: Optional[Union[go.Layout, Dict[str, Any]]] = None,
    palettes: Optional[Palettes] = None,
    piemap: Optional[Union[PieMapStyle, Dict[str, Any]]] = None,
    tree: Optional[Union[TreeStyle, Dict[str, Any]]] = None,
    legend: Optional[Union[LegendStyle, Dict[str, Any]]] = None,
    show_legend: Optional[bool] = None,
    row_col_numbers: Optional[bool] = None,
    xstep: Optional[str] = None,
    ystep: Optional[str] = None,
):
    super().__init__(
        boxsize=boxsize,
        config=config,
        highlight_annotation=highlight_annotation,
        highlight_color=highlight_color,
        labels=labels,
        layout=layout,
        palettes=palettes,
        piemap=piemap,
        tree=tree,
        legend=legend,
        show_legend=show_legend,
        row_col_numbers=row_col_numbers,
        xstep=xstep,
        ystep=ystep,
    )

boxsize

boxsize() -> int

Size in pixels per row or column.

Source code in ragraph/plot/generic.py
@field
def boxsize(self) -> int:  # type: ignore
    """Size in pixels per row or column."""

config

config() -> Dict[str, Any]

Plotly Figure.show() config.

Source code in ragraph/plot/generic.py
@field
def config(self) -> Dict[str, Any]:  # type: ignore
    """Plotly Figure.show() config."""

highlight_annotation

highlight_annotation() -> Optional[str]

Annotation key of instances that should be highlighted. Value should be True-ish. Set key to None to disable.

Source code in ragraph/plot/generic.py
@field
def highlight_annotation(self) -> Optional[str]:  # type: ignore
    """Annotation key of instances that should be highlighted.
    Value should be True-ish. Set key to `None` to disable."""

highlight_color

highlight_color() -> str

Default color to use for highlights.

Source code in ragraph/plot/generic.py
@field
def highlight_color(self) -> str:  # type: ignore
    """Default color to use for highlights."""

labels

labels() -> LabelsStyle

Labels plot style.

Source code in ragraph/plot/generic.py
@field
def labels(self) -> LabelsStyle:  # type: ignore
    """Labels plot style."""

layout

layout() -> go.Layout

Layout options.

Source code in ragraph/plot/generic.py
@field
def layout(self) -> go.Layout:  # type: ignore
    """Layout options."""

legend

legend() -> LegendStyle

Legend plot style.

Source code in ragraph/plot/generic.py
@field
def legend(self) -> LegendStyle:  # type: ignore
    """Legend plot style."""

palettes

palettes() -> Palettes

Plot palettes options.

Source code in ragraph/plot/generic.py
@field
def palettes(self) -> Palettes:  # type: ignore
    """Plot palettes options."""

piemap

piemap() -> PieMapStyle

Piechart map plot style.

Source code in ragraph/plot/generic.py
@field
def piemap(self) -> PieMapStyle:  # type: ignore
    """Piechart map plot style."""

row_col_numbers

row_col_numbers() -> bool

Boolean to display row and column numbers.

Source code in ragraph/plot/generic.py
@field
def row_col_numbers(self) -> bool:  # type: ignore
    """Boolean to display row and column numbers."""

show_legend

show_legend() -> bool

Boolean to display a legend.

Source code in ragraph/plot/generic.py
@field
def show_legend(self) -> bool:  # type: ignore
    """Boolean to display a legend."""

tree

tree() -> TreeStyle

Tree plot style.

Source code in ragraph/plot/generic.py
@field
def tree(self) -> TreeStyle:  # type: ignore
    """Tree plot style."""

xstep

xstep() -> float

Axis increment per row or column in plots (usually 1).

Source code in ragraph/plot/generic.py
@field
def xstep(self) -> float:  # type: ignore
    """Axis increment per row or column in plots (usually 1)."""

ystep

ystep() -> float

Axis increment per row or column in plots (usually 1).

Source code in ragraph/plot/generic.py
@field
def ystep(self) -> float:  # type: ignore
    """Axis increment per row or column in plots (usually 1)."""

delta_dsm

1
2
3
4
5
6
7
delta_dsm(
    g1: Graph,
    g2: Graph,
    *args,
    style: Style = Style(),
    **kwargs
) -> go.Figure

Get a delta-DSM plot between two Graph objects.

Source code in ragraph/plot/__init__.py
def delta_dsm(g1: Graph, g2: Graph, *args, style: Style = Style(), **kwargs) -> go.Figure:
    """Get a delta-DSM plot between two Graph objects."""
    raise NotImplementedError()

dmm

dmm(
    rows: List[Node],
    cols: List[Node],
    edges: List[Edge],
    style: Style = Style(),
    sort: bool = True,
    row_node_kinds: Optional[List[str]] = None,
    row_sort_args: Dict[str, Any] = dict(),
    col_node_kinds: Optional[List[str]] = None,
    col_sort_args: Dict[str, Any] = dict(),
    show: bool = False,
) -> go.Figure

Get a domain-mapping-matrix (DMM) plot of a Graph object.

Parameters:

Name Type Description Default
rows List[Node]

The nodes to be placed on the rows of the matrix.

required
cols List[Node]

The columns to be placed on the columns of the matrix.

required
edges List[Edge]

Edges to be displayed between leaf nodes.

required
style Style

Plot style option mapping.

Style()
sort bool

Boolean to indicate whether the rows and cols should be sorted following the hierarchical structure.

True
row_node_kinds Optional[List[str]]

The node kinds displayed on the rows.

None
col_node_kinds Optional[List[str]]

The node kinds displayed on the columns.

None
show bool

Boolean to display the figure.

False

Returns:

Type Description
Figure

Domain-mapping matrix figure.

Source code in ragraph/plot/__init__.py
def dmm(
    rows: List[Node],
    cols: List[Node],
    edges: List[Edge],
    style: Style = Style(),
    sort: bool = True,
    row_node_kinds: Optional[List[str]] = None,
    row_sort_args: Dict[str, Any] = dict(),
    col_node_kinds: Optional[List[str]] = None,
    col_sort_args: Dict[str, Any] = dict(),
    show: bool = False,
) -> go.Figure:
    """Get a domain-mapping-matrix (DMM) plot of a Graph object.

    Arguments:
        rows: The nodes to be placed on the rows of the matrix.
        cols: The columns to be placed on the columns of the matrix.
        edges: Edges to be displayed between leaf nodes.
        style: Plot style option mapping.
        sort: Boolean to indicate whether the rows and cols should be sorted following
            the hierarchical structure.
        row_node_kinds: The node kinds displayed on the rows.
        col_node_kinds: The node kinds displayed on the columns.
        show: Boolean to display the figure.

    Returns:
       Domain-mapping matrix figure.
    """
    from ragraph.plot import utils

    if sort:
        rows = utils.get_axis_sequence(rows, kinds=row_node_kinds, **row_sort_args)
        cols = utils.get_axis_sequence(cols, kinds=col_node_kinds, **col_sort_args)

    grid = utils.get_dmm_grid(rows=rows, cols=cols, edges=edges, style=style)

    fig = utils.get_subplots(grid, style=style)
    return utils.process_fig(fig=fig, show=show, style=style)

dsm

1
2
3
4
5
6
7
8
9
dsm(
    leafs: List[Node],
    edges: List[Edge],
    style: Style = Style(),
    sort: bool = True,
    sort_args: Dict[str, Any] = dict(),
    node_kind: Optional[str] = None,
    show: bool = False,
) -> go.Figure

Get a DSM plot of a Graph object.

Arguments leafs: The nodes to be placed on the rows and columns of the matrix.. edges: Edges to be displayed between leaf nodes. style: Plot style option mapping. sort: Boolean to indicate whether the rows and cols should be sorted following the hierarchical structure. node_kind: The node kind to be displayed. show: Boolean to display the figure.

Source code in ragraph/plot/__init__.py
def dsm(
    leafs: List[Node],
    edges: List[Edge],
    style: Style = Style(),
    sort: bool = True,
    sort_args: Dict[str, Any] = dict(),
    node_kind: Optional[str] = None,
    show: bool = False,
) -> go.Figure:
    """Get a DSM plot of a Graph object.

    Arguments
        leafs: The nodes to be placed on the rows and columns of the matrix..
        edges: Edges to be displayed between leaf nodes.
        style: Plot style option mapping.
        sort: Boolean to indicate whether the rows and cols should be sorted following
            the hierarchical structure.
        node_kind: The node kind to be displayed.
        show: Boolean to display the figure.
    """
    node_kinds = [node_kind] if node_kind else list({n.kind for n in leafs})
    assert (
        len(node_kinds) == 1
    ), "A DSM should only contain one node kind. See MDM for multi-domain matrices."

    return mdm(
        leafs,
        edges,
        style=style,
        sort=sort,
        sort_args=sort_args,
        node_kinds=node_kinds,
        show=show,
    )

mdm

1
2
3
4
5
6
7
8
9
mdm(
    leafs: List[Node],
    edges: List[Edge],
    style: Style = Style(),
    sort: bool = True,
    sort_args: Dict[str, Any] = dict(),
    node_kinds: Optional[List[str]] = None,
    show: bool = False,
) -> go.Figure

Get a Multi-Domain Matrix (MDM) plot of a Graph object.

Arguments leafs: The nodes to be placed on the rows and columns of the matrix.. edges: Edges to be displayed between leaf nodes. style: Plot style option mapping. sort: Boolean to indicate whether the rows and cols should be sorted following the hierarchical structure. node_kinds: The node kinds displayed within the matrix. show: Boolean to display the figure.

Source code in ragraph/plot/__init__.py
def mdm(
    leafs: List[Node],
    edges: List[Edge],
    style: Style = Style(),
    sort: bool = True,
    sort_args: Dict[str, Any] = dict(),
    node_kinds: Optional[List[str]] = None,
    show: bool = False,
) -> go.Figure:
    """Get a Multi-Domain Matrix (MDM) plot of a Graph object.

    Arguments
        leafs: The nodes to be placed on the rows and columns of the matrix..
        edges: Edges to be displayed between leaf nodes.
        style: Plot style option mapping.
        sort: Boolean to indicate whether the rows and cols should be sorted following
            the hierarchical structure.
        node_kinds: The node kinds displayed within the matrix.
        show: Boolean to display the figure.
    """
    from ragraph.plot import utils

    if sort:
        leafs = utils.get_axis_sequence(leafs, kinds=node_kinds, **sort_args)

    grid = utils.get_mdm_grid(leafs=leafs, edges=edges, style=style)

    fig = utils.get_subplots(grid, style=style)

    return utils.process_fig(fig=fig, show=show, style=style)

network

1
2
3
network(
    g: Graph, *args, style: Style = Style(), **kwargs
) -> go.Figure

Get a network plot of a Graph object.

Source code in ragraph/plot/__init__.py
def network(g: Graph, *args, style: Style = Style(), **kwargs) -> go.Figure:
    """Get a network plot of a Graph object."""
    raise NotImplementedError()

sigma_dsm

1
2
3
4
5
6
sigma_dsm(
    graphs: Iterable[Graph],
    *args,
    style: Style = Style(),
    **kwargs
) -> go.Figure

Get a sigma-DSM plot of any number of Graph objects.

Source code in ragraph/plot/__init__.py
def sigma_dsm(graphs: Iterable[Graph], *args, style: Style = Style(), **kwargs) -> go.Figure:
    """Get a sigma-DSM plot of any number of Graph objects."""
    raise NotImplementedError()