Skip to content

Commit 3898a89

Browse files
authored
Merge pull request #51 from petercorke/feat/plot-arrows
feat: plot() draws arrowheads, parallel edges and loops; clearer option names
2 parents 5acb105 + c57e94b commit 3898a89

6 files changed

Lines changed: 819 additions & 120 deletions

File tree

‎docs/source/visualization.rst‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@ Rendering the graph itself, with matplotlib or via GraphViz. See
55
:doc:`export` for exporting the graph as data or an image file (dot, Mermaid,
66
GraphML, ELK, PNG, ...) and :doc:`representations` for its matrices.
77

8+
:meth:`~pgraph.PGraph.Graph.plot` draws each edge once. A directed graph has an
9+
arrowhead at the end of each edge, edges that join the same pair of vertices
10+
are drawn as arcs that bow apart so that parallel and antiparallel edges can all
11+
be seen, and a loop is drawn as a circle at its vertex. The same is true of a
12+
3D plot, which follows a rotation of the view.
13+
14+
The appearance is set by dicts of Matplotlib options:
15+
16+
================= ==================================================== =============================
17+
option applies to default
18+
================= ==================================================== =============================
19+
``vertex_opt`` the vertex marker (``plot``) ``marker="o", markersize=12``
20+
``edge_opt`` the edge line (``FancyArrowPatch``): ``color``, ``linewidth=3``
21+
``linewidth``, ``linestyle``, ``alpha``
22+
``arrow_opt`` the arrowhead and the path: ``arrowstyle``, ``arrowstyle="-|>",``
23+
``mutation_scale``, ``connectionstyle`` ``mutation_scale=15`` for a
24+
directed graph, ``"-"``
25+
for an undirected one
26+
``text_opt`` the vertex labels (``text``) Matplotlib's
27+
================= ==================================================== =============================
28+
29+
``labels=False`` removes the labels, and ``color_components=False`` draws the
30+
graph in one color rather than a color for each component.
31+
32+
.. note:: The options were named ``vopt``, ``eopt``, ``text``, ``colorcomponents``
33+
and ``force2d`` in 0.6.5. Those names still work but give a
34+
``DeprecationWarning``.
35+
836
.. autosummary::
937
:nosignatures:
1038

0 commit comments

Comments
 (0)