.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/03_node_link/plot_09_layouts.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 or to run this example in your browser via Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_03_node_link_plot_09_layouts.py: Six layouts of the same hypergraph ================================== The HAT-VIS similarity layout places similar vertices close to each other; the HyperGodot force-directed layout balances centroid springs and repulsion; the membership-aware layout of hatvis keeps the similarity geometry but pushes non-members out of hyperedge discs; the circular, spectral and bipartite layouts are classical alternatives. The layout quality table reports the stress against the similarity distances and the number of intrusions (non-members inside a hull). .. GENERATED FROM PYTHON SOURCE LINES 15-29 .. code-block:: Python import matplotlib.pyplot as plt import pandas as pd import hatvis as hv from hatvis.plotting import draw_hypergraph, resolve_layout H = hv.datasets.load_manufacturing_cps() names = ["similarity", "force", "membership", "circular", "spectral", "bipartite"] # [snippet:layouts] layouts = {name: resolve_layout(H, None, name, random_state=0) for name in names} quality = pd.DataFrame({name: hv.layout_quality(H, pos) for name, pos in layouts.items()}).T print(quality.round(3)) # [/snippet:layouts] .. rst-class:: sphx-glr-script-out .. code-block:: none stress intrusions hyperedges with intrusions mean hull area similarity 0.080 2.0 2.0 0.034 force 0.126 1.0 1.0 0.091 membership 0.051 0.0 0.0 0.049 circular 0.084 0.0 0.0 0.089 spectral 0.100 6.0 5.0 0.037 bipartite 0.137 0.0 0.0 0.026 .. GENERATED FROM PYTHON SOURCE LINES 30-34 .. code-block:: Python fig, axes = plt.subplots(2, 3, figsize=(15, 9.5)) for ax, (name, pos) in zip(axes.ravel(), layouts.items(), strict=False): draw_hypergraph(H, pos=pos, ax=ax, legend=False, title=f"{name} (intrusions: {int(quality.loc[name, 'intrusions'])})") plt.tight_layout() .. image-sg:: /auto_examples/03_node_link/images/sphx_glr_plot_09_layouts_001.png :alt: similarity (intrusions: 2), force (intrusions: 1), membership (intrusions: 0), circular (intrusions: 0), spectral (intrusions: 6), bipartite (intrusions: 0) :srcset: /auto_examples/03_node_link/images/sphx_glr_plot_09_layouts_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.808 seconds) .. _sphx_glr_download_auto_examples_03_node_link_plot_09_layouts.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/ComplexSystemsIntelligence/hatvis/main?urlpath=lab/tree/notebooks/auto_examples/03_node_link/plot_09_layouts.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_09_layouts.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_09_layouts.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_09_layouts.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_