NetworkArtist

class compas.artists.NetworkArtist(item, **kwargs)[source]

Bases: Artist

Artist for drawing network data structures.

Parameters
  • network (Network) – A COMPAS network.

  • nodes (list[hashable], optional) – A list of node identifiers. Default is None, in which case all nodes are drawn.

  • edges (list[tuple[hashable, hashable]], optional) – A list of edge keys (as uv pairs) identifying which edges to draw. The default is None, in which case all edges are drawn.

  • nodecolor (Color | dict[hashable, Color], optional) – The color specification for the nodes.

  • edgecolor (Color | dict[tuple[hashable, hashable]], Color], optional) – The color specification for the edges.

Attributes
  • network (Network) – The COMPAS network associated with the artist.

  • nodes (list[hashable]) – The list of nodes to draw. Defaults to all nodes.

  • edges (list[tuple[hashable, hashable]]) – The list of edges to draw. Default is a list of all edges of the network.

  • node_xyz (dict[hashable, list[float]]) – Mapping between nodes and their view coordinates. The default view coordinates are the actual coordinates of the nodes of the network.

  • node_color (dict[hashable, Color]) – Mapping between nodes and RGB color values. Missing nodes get the default node color default_nodecolor.

  • edge_color (dict[tuple[hashable, hashable], Color]) – Mapping between edges and colors. Missing edges get the default edge color default_edgecolor.

  • node_text (dict[hashable, str]) – Mapping between nodes and text labels.

  • edge_text (dict[tuple[hashable, hashable], str]) – Mapping between edges and text labels.

  • node_size (dict[hashable, float]) – Mapping between nodes and sizes. Missing nodes get assigned the default node size default_nodesize.

  • edge_width (dict[tuple[hashable, hashable], float]) – Mapping between edges and line widths. Missing edges get assigned the default edge width default_edgewidth.

Class Attributes
  • default_nodecolor (Color) – The default color for nodes that do not have a specified color.

  • default_edgecolor (Color) – The default color for edges that do not have a specified color.

  • default_nodesize (float) – The default size for nodes that do not have a specified size.

  • default_edgewidth (float) – The default width for edges that do not have a specified width.

Methods

clear

Clear the nodes and the edges of the network.

clear_edges

Clear the edges of the network.

clear_nodes

Clear the nodes of the network.

draw_edges

Draw the edges of the network.

draw_nodes

Draw the nodes of the network.

Inherited Methods

build

Build an artist corresponding to the item type.

build_as

Build an artist with the given type.

draw

The main drawing method.

draw_collection

Drawing method for drawing an entire collection of objects.

redraw

Redraw the view.

register

Register an artist type to a data type.