.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_gallery_graph_structure_plot_hive_panel.py>`     to download the full example code
    .. rst-class:: sphx-glr-example-title

    .. _sphx_glr_gallery_graph_structure_plot_hive_panel.py:


Hive plot panel
===============



.. image:: /gallery/graph_structure/images/sphx_glr_plot_hive_panel_001.png
    :alt: strength, cc, flux
    :class: sphx-glr-single-img






.. code-block:: default


    import os

    import matplotlib.pyplot as plt

    import nngt


    dirpath  = os.path.abspath(os.getcwd())
    rootpath = os.path.abspath(dirpath + "/../../..")


    # load graph

    g = nngt.load_from_file(rootpath + "/testing/Networks/rat_brain.graphml",
                            attributes=["weight"], cleanup=True,
                            attributes_types={"weight": float})


    # prepare attributes

    cc = nngt.analysis.local_clustering(g, weights="weight")

    g.new_node_attribute("cc", "double", values=cc)

    g.new_node_attribute("strength", "double",
                         values=g.get_degrees(weights="weight"))

    flux = g.get_degrees("out") - g.get_degrees("in")

    g.new_node_attribute("flux", "double", values=flux)


    # figure parameters

    cc_bins = [0, 0.1, 0.25, 0.6]

    todo = ["strength", "cc", "flux"]
    bins = [3, cc_bins, 3]


    # make plot

    fig, axes = plt.subplots(len(todo), len(todo), figsize=(10, 9))

    for i in range(len(todo)):
        radial = todo[i]

        for j in range(len(todo)):
            ax_name = todo[j]
            ax_bins = bins[j]

            ax = axes[i, j]

            if i == 0:
                ax.set_title(ax_name)

            if j == 0:
                ax.set_ylabel(radial)

            size = todo[list(set([0, 1, 2]).difference([i, j]))[0]]

            nngt.plot.hive_plot(
                g, radial, axes=ax_name, edge_alpha=0.1, nsize=size, max_nsize=50,
                axes_bins=ax_bins, axes_units="native", axis=ax, show_names=False)

    for i in range(len(todo)):
        fig.text(0.03, 0.8 - i*0.33, todo[i], rotation=90, fontsize="large")

    plt.tight_layout()

    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  14.908 seconds)


.. _sphx_glr_download_gallery_graph_structure_plot_hive_panel.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example



  .. container:: sphx-glr-download sphx-glr-download-python

     :download:`Download Python source code: plot_hive_panel.py <plot_hive_panel.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: plot_hive_panel.ipynb <plot_hive_panel.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
