.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/network_science/plot_simple_networkx.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_network_science_plot_simple_networkx.py: Simple example from networkx ============================ This example demonstrates how to use `iplotx` with `networkx`. Note how the vertex size is computed dynamically based on label size. .. GENERATED FROM PYTHON SOURCE LINES 8-48 .. image-sg:: /gallery/network_science/images/sphx_glr_plot_simple_networkx_001.png :alt: plot simple networkx :srcset: /gallery/network_science/images/sphx_glr_plot_simple_networkx_001.png :class: sphx-glr-single-img .. code-block:: Python import networkx as nx import matplotlib.pyplot as plt import iplotx as ipx G = nx.Graph() G.add_edge(1, 2) G.add_edge(1, 3) G.add_edge(1, 5) G.add_edge(2, 3) G.add_edge(3, 4) G.add_edge(4, 5) # explicitly set positions pos = {1: (0, 0), 2: (-1, 0.3), 3: (2, 0.17), 4: (4, 0.255), 5: (5, 0.03)} ipx.network( G, layout=pos, vertex_labels=True, style={ "vertex": { "size": "label", "facecolor": "white", "edgecolor": "black", "linewidth": 5, "label": { "size": 26, "color": "black", }, }, "edge": { "linewidth": 5, }, }, ) # Set margins for the axes so that nodes aren't clipped ax = plt.gca() ax.margins(0.20) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.051 seconds) .. _sphx_glr_download_gallery_network_science_plot_simple_networkx.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_simple_networkx.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_simple_networkx.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_simple_networkx.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_