iddn.visualize_basic ==================== .. py:module:: iddn.visualize_basic .. autoapi-nested-parse:: Some shared basic visualization functions 1. Find positions of each node in each group (line or ellipse) 2. Add text outside the circle or line Functions --------- .. autoapisummary:: iddn.visualize_basic.get_pos_multi_parts iddn.visualize_basic._get_pos_one_part iddn.visualize_basic._get_pos_one_part_line iddn.visualize_basic.draw_network_labels iddn.visualize_basic._add_node_to_a_circle iddn.visualize_basic._angles_in_ellipse Module Contents --------------- .. py:function:: 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. :param nodes_all: Node names :type nodes_all: list of str :param nodes_type: Component/grouping name (or index) for each node :type nodes_type: dict :param cen_lst: 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) :type cen_lst: array_like :param rad_lst: 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. :type rad_lst: array_like :returns: * **pos** (*dict*) -- The positions for each node * **d_min** (*float*) -- Minimum distances between nodes .. py:function:: _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. :param nodes_show: Node names :type nodes_show: tuple of str :param cen: The center of ellipse for each type of node. Shape (2, ) :type cen: ndarray, optional :param rad: The radius of ellipse for each type of node. Shape (2, ) :type rad: ndarray, optional :param pos: NetworkX-like position dictionary :type pos: dict :returns: * **pos** (*dict*) -- The positions for each node * **d_min** (*float*) -- Minimum distances between nodes .. py:function:: _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. :param nodes_show: Node names :type nodes_show: tuple of str :param cen: The center of ellipse for each type of node. Shape (2, ) :type cen: ndarray :param rad: The half-length of the line segment :type rad: float or int :param pos: NetworkX-like position dictionary :type pos: dict :returns: * **pos** (*dict*) -- The positions for each node * **d_min** (*float*) -- Minimum distances between nodes .. py:function:: 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 :param ax: The axes of the figure :type ax: matplotlib.axes.Axes :param pos: Node position dictionary :type pos: dict :param d_min: Minimum distance between nodes :type d_min: float :param node_type: Feature type index of each node :type node_type: dict :param cen_lst: The center of each component. :type cen_lst: array_like :param rad_lst: The radius of each component. :type rad_lst: array_like :param labels: Alternative names for each node, to be shown in the graph :type labels: dict :param font_size_lst: Font size for each node, in points :type font_size_lst: array_like :param font_alpha_lst: Font alpha for each node, value from 0 to 1 :type font_alpha_lst: array_like :param font_col_lst: Font color for each node :type font_col_lst: array_like .. py:function:: _add_node_to_a_circle(pos, nodes, cen, rad, angles) Find positions in an ellipse, and calculate the minimum distances between points :param pos: For saving the position results for NetworkX :type pos: dict :param nodes: Name of nodes :type nodes: list of str :param cen: Central position of this circle, shape (2,) :type cen: array_like :param rad: Length of two axes of the ellipse, shape (2,) :type rad: array_like :param angles: Angles of the points :type angles: array_like :returns: Minimum distances between points :rtype: float .. py:function:: _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/ :param num: Sample number to get :type num: int :param a: Length of shorter axis :type a: float :param b: Length of longer axis :type b: float :returns: **angles** -- Angles of sampled points :rtype: ndarray