You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -12,8 +12,8 @@ DHG provides a simple interface to visualize the correlation structures:
12
12
13
13
1. Create a structure object (*i.e.*, :py:class:`dhg.Graph`, :py:class:`dhg.BiGraph`, :py:class:`dhg.DiGraph`, and :py:class:`dhg.Hypergraph`);
14
14
2. Call the ``draw()`` method of the object;
15
-
3. Call ``plt.show()`` to show the figure or ``plt.savefig()`` to save the figure.
16
-
15
+
3. Call ``plt.show()`` to show the figure or ``plt.savefig()`` to save the figure.
16
+
17
17
.. note:: The ``plt`` is short for ``matplotlib.pyplot`` module.
18
18
19
19
@@ -40,7 +40,7 @@ Visualization of Directed Graph
40
40
41
41
.. image:: ../_static/img/vis_digraph.png
42
42
:align:center
43
-
:alt:Visualization of Directed Graph
43
+
:alt:Visualization of Directed Graph
44
44
:height:400px
45
45
46
46
.. code-block:: python
@@ -93,19 +93,69 @@ Advanced Usages
93
93
94
94
Customize Labels
95
95
^^^^^^^^^^^^^^^^^^^^^^^^^
96
-
Coming soon...
96
+
The labels of the vertices could be customized by the ``v_label`` argument. The ``v_label`` could be a list of strings. The labels of the vertices are the strings in the list.
97
+
For example, the following code shows how to customize the labels of the vertices of a graph.
98
+
If the ``v_label`` is not specified, no labels will be shown in the figure.
99
+
The ``font_size`` argument for ``dhg.Graph``, ``dhg.DiGraph``, and ``dhg.Hypergraph``, as well as ``u_font_size`` and ``v_font_size`` for ``dhg.BiGraph`` is used to specify the relative size of the font of the labels, and the default value is ``1.0``.
100
+
The ``font_family`` argument is used to specify the font family of the labels, and the default value is ``'sans-serif'``.
For ``dhg.Graph``, ``dhg.DiGraph``, and ``dhg.Hypergraph``, the colors of the vertices could be customized by the ``v_color`` argument and the colors of the edges could be customized by the ``e_color`` argument. While for ``dhg.BiGraph``, the colors of the vertices in :math:`\mathcal{U}` could be customized by the ``u_color`` argument and the colors of the vertices in :math:`\mathcal{V}` could be customized by the ``v_color`` argument. Both the ``v_color``, ``u_color``, and ``e_color`` could be a string or list of strings. If a string is provided, all the vertices or edges will be colored by the string. If a list of strings is provided, the colors of the vertices or edges are the strings in the list. For example, the following code shows how to customize the colors of the vertices and edges of a hypergraph.
For ``dhg.Graph``, ``dhg.DiGraph``, and ``dhg.Hypergraph``, the sizes of the vertices could be customized by the ``v_size`` argument and the sizes of the edges could be customized by the ``e_size`` argument. While for ``dhg.BiGraph``, the sizes of the vertices in :math:`\mathcal{U}` could be customized by the ``u_size`` argument and the sizes of the vertices in :math:`\mathcal{V}` could be customized by the ``v_size`` argument. Both the ``v_size``, ``u_size``, and ``e_size`` could be a float or list of float. If a float is provided, all the vertices or edges will be sized by the float. If a list of floats is provided, the sizes of the vertices or edges are the floats in the list. ``v_line_width`` represents the width of the surrounding line of the vertices. ``e_line_width`` represents the width of the line of the edges.
138
+
All of the sizes above represent the relative size, and the default values are ``1.0``. For example, the following code shows how to customize the sizes of the vertices and edges of a hypergraph.
The layout of the structures is based on the modified directed-force layout algorithm. There are four forces to determine the position of the nodes, *i.e.*, node attraction force :math: `f_{na}`, node repulsion force :math: `f_{nr}`, edge repulsion force :math: `f_{er}`, and the center force :math: `f_c`. :math: `f_{na}` is the spring force which attracts the adjacent nodes. :math: `f_{nr}` is used to repel the nodes from each other. :math: `f_{er}` is used to repel the hyperedges from each other, which only make sense for hypergraph visualization. :math: `f_c` is used to attract the nodes to the center (two centers for the bipartite graphs).
158
+
The strength of the forces could be customized by ``forces`` argument, which is a dictionary with the keys ``Simulator.NODE_ATTRACTION``, ``Simulator.NODE_REPULSION``, ``Simulator.EDGE_REPULSION``, and ``Simulator.CENTER_GRAVITY``. The default values of the forces are ``1.0``.
109
159
110
160
111
161
.. different style, change size, change color, change opacity
0 commit comments