.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/graph_structure/plot_chord_diagram.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_graph_structure_plot_chord_diagram.py: Chord diagram ============= .. GENERATED FROM PYTHON SOURCE LINES 10-55 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /gallery/graph_structure/images/sphx_glr_plot_chord_diagram_001.png :alt: plot chord diagram :srcset: /gallery/graph_structure/images/sphx_glr_plot_chord_diagram_001.png :class: sphx-glr-multi-img * .. image-sg:: /gallery/graph_structure/images/sphx_glr_plot_chord_diagram_002.png :alt: plot chord diagram :srcset: /gallery/graph_structure/images/sphx_glr_plot_chord_diagram_002.png :class: sphx-glr-multi-img .. code-block:: Python import matplotlib.pyplot as plt import nngt plt.rcParams["figure.facecolor"] = (0, 0, 0, 0) nngt.seed(0) # create a structured graph room1 = nngt.Group(25) room2 = nngt.Group(50) room3 = nngt.Group(40) room4 = nngt.Group(35) names = ["R1", "R2", "R3", "R4"] struct = nngt.Structure.from_groups((room1, room2, room3, room4), names) g = nngt.Graph(structure=struct, directed=True) for room in struct: nngt.generation.connect_groups(g, room, room, "all_to_all") nngt.generation.connect_groups(g, (room1, room2), struct, "erdos_renyi", avg_deg=10, ignore_invalid=True) nngt.generation.connect_groups(g, room3, room1, "erdos_renyi", avg_deg=20) nngt.generation.connect_groups(g, room4, room3, "erdos_renyi", avg_deg=10) # get the structure graph and plot sg = g.get_structure_graph() # undirected version of the chord diagram nngt.plot.chord_diagram(sg, names="name", sort="distance", fontcolor="grey", use_gradient=True, directed=False, show=False) # directed chord diagram nngt.plot.chord_diagram(sg, names="name", sort="distance", fontcolor="grey", use_gradient=True, directed=True, show=True) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.083 seconds) .. _sphx_glr_download_gallery_graph_structure_plot_chord_diagram.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_chord_diagram.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_chord_diagram.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_