.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/basic/plot_house.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_basic_plot_house.py: Plot a house ============ This example from networkx shows how to integrate network attributes/data and plotting. .. GENERATED FROM PYTHON SOURCE LINES 7-44 .. image-sg:: /gallery/basic/images/sphx_glr_plot_house_001.png :alt: plot house :srcset: /gallery/basic/images/sphx_glr_plot_house_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.house_graph() fig, ax = plt.subplots() nx.set_node_attributes(G, {0: (0, 0), 1: (1, 0), 2: (0, 1), 3: (1, 1), 4: (0.5, 2.0)}, "pos") nx.set_node_attributes( G, { n: { "size": 60 if n != 4 else 40, "color": "tab:blue" if n != 4 else "tab:orange", } for n in G.nodes() }, ) ipx.plot( G, ax=ax, layout="pos", style={ "edge": { "alpha": 0.5, "linewidth": 6, }, # You could use "vertex" instead of "node" "node": { "size": G.nodes.data("size"), "facecolor": G.nodes.data("color"), "edgecolor": "k", }, }, ) ax.margins(0.17) plt.tight_layout() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.038 seconds) .. _sphx_glr_download_gallery_basic_plot_house.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_house.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_house.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_house.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_