iddn.visualize_basic
Some shared basic visualization functions
Find positions of each node in each group (line or ellipse)
Add text outside the circle or line
Functions
|
Find positions of nodes with multiple isolated components or sub-graphs. |
|
Find positions of nodes on an ellipse |
|
Find positions of nodes on a line segment |
|
Add labels to a graph |
|
Find positions in an ellipse, and calculate the minimum distances between points |
|
Calculate angles of evenly spaced points in an ellipse |
Module Contents
- iddn.visualize_basic.get_pos_multi_parts(nodes_all, nodes_type, cen_lst=np.array([[-0.6, 0], [0.6, 0]]), rad_lst=np.array([[0.4, 1], [0.4, 1]]))
Find positions of nodes with multiple isolated components or sub-graphs.
Each subgraph is an ellipse or a line segment. Also provides the minimum distances between nodes.
Let K be the number of components to draw.
- Parameters:
nodes_all (list of str) – Node names
nodes_type (dict) – Component/grouping name (or index) for each node
cen_lst (array_like) – The center of each component. For component whose index is i, set cen_lst[i] Shape (k, 2), k is the number of types. 2 for (x, y)
rad_lst (array_like) – The radius of each component. For component whose index is i, set rad_lst[i] Shape (k, 2), k is the number of types. 2 for shorter and longer axis length.
- Returns:
pos (dict) – The positions for each node
d_min (float) – Minimum distances between nodes
- iddn.visualize_basic._get_pos_one_part(nodes_show, cen=(0.0, 0.0), rad=(1.0, 1.0), pos=None)
Find positions of nodes on an ellipse
Also provides the minimum distances between nodes.
- Parameters:
nodes_show (tuple of str) – Node names
cen (ndarray, optional) – The center of ellipse for each type of node. Shape (2, )
rad (ndarray, optional) – The radius of ellipse for each type of node. Shape (2, )
pos (dict) – NetworkX-like position dictionary
- Returns:
pos (dict) – The positions for each node
d_min (float) – Minimum distances between nodes
- iddn.visualize_basic._get_pos_one_part_line(nodes_show, cen=(0.0, 0.0), rad=1.0, pos=None)
Find positions of nodes on a line segment
Also provides the minimum distances between nodes.
- Parameters:
nodes_show (tuple of str) – Node names
cen (ndarray) – The center of ellipse for each type of node. Shape (2, )
rad (float or int) – The half-length of the line segment
pos (dict) – NetworkX-like position dictionary
- Returns:
pos (dict) – The positions for each node
d_min (float) – Minimum distances between nodes
- iddn.visualize_basic.draw_network_labels(ax, pos, d_min, node_type, cen_lst, rad_lst, labels, font_size_lst, font_alpha_lst, font_col_lst)
Add labels to a graph
Modified from Networkx add label function
- Parameters:
ax (matplotlib.axes.Axes) – The axes of the figure
pos (dict) – Node position dictionary
d_min (float) – Minimum distance between nodes
node_type (dict) – Feature type index of each node
cen_lst (array_like) – The center of each component.
rad_lst (array_like) – The radius of each component.
labels (dict) – Alternative names for each node, to be shown in the graph
font_size_lst (array_like) – Font size for each node, in points
font_alpha_lst (array_like) – Font alpha for each node, value from 0 to 1
font_col_lst (array_like) – Font color for each node
- iddn.visualize_basic._add_node_to_a_circle(pos, nodes, cen, rad, angles)
Find positions in an ellipse, and calculate the minimum distances between points
- Parameters:
pos (dict) – For saving the position results for NetworkX
nodes (list of str) – Name of nodes
cen (array_like) – Central position of this circle, shape (2,)
rad (array_like) – Length of two axes of the ellipse, shape (2,)
angles (array_like) – Angles of the points
- Returns:
Minimum distances between points
- Return type:
float
- iddn.visualize_basic._angles_in_ellipse(num, a, b)
Calculate angles of evenly spaced points in an ellipse
Based on https://stackoverflow.com/a/52062369, which is from https://pypi.org/project/flyingcircus/
- Parameters:
num (int) – Sample number to get
a (float) – Length of shorter axis
b (float) – Length of longer axis
- Returns:
angles – Angles of sampled points
- Return type:
ndarray