
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/graph_properties/plot_degrees.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

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

        Click :ref:`here <sphx_glr_download_gallery_graph_properties_plot_degrees.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_graph_properties_plot_degrees.py:


Plot the degree distributions of a graph
========================================

.. GENERATED FROM PYTHON SOURCE LINES 24-40

.. code-block:: default


    import nngt
    import nngt.plot as nplt

    import matplotlib.pyplot as plt

    plt.rcParams.update({
        'axes.edgecolor': 'grey', 'xtick.color': 'grey', 'ytick.color': 'grey',
        "figure.facecolor": (0, 0, 0, 0), "axes.facecolor": (0, 0, 0, 0),
        "axes.labelcolor": "grey", "text.color": "grey", "legend.facecolor": "none"
    })


    nngt.seed(0)









.. GENERATED FROM PYTHON SOURCE LINES 41-42

First, let's create a scale-free network

.. GENERATED FROM PYTHON SOURCE LINES 42-46

.. code-block:: default


    g = nngt.generation.random_scale_free(2.1, 3.2, nodes=1000, avg_deg=100)









.. GENERATED FROM PYTHON SOURCE LINES 47-48

Plot the degree distribution

.. GENERATED FROM PYTHON SOURCE LINES 48-51

.. code-block:: default


    nplt.degree_distribution(g, deg_type=["in", "out"], show=True)




.. image-sg:: /gallery/graph_properties/images/sphx_glr_plot_degrees_001.png
   :alt: Degree distribution for RandomSF
   :srcset: /gallery/graph_properties/images/sphx_glr_plot_degrees_001.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 52-53

It's not bad... but we don't see much! Let's move a more relevant scale

.. GENERATED FROM PYTHON SOURCE LINES 53-57

.. code-block:: default


    nplt.degree_distribution(g, deg_type=["in", "out"], logy=True, show=True)





.. image-sg:: /gallery/graph_properties/images/sphx_glr_plot_degrees_002.png
   :alt: Degree distribution for RandomSF
   :srcset: /gallery/graph_properties/images/sphx_glr_plot_degrees_002.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 58-59

Or we can use Bayesian binning

.. GENERATED FROM PYTHON SOURCE LINES 59-62

.. code-block:: default


    nplt.degree_distribution(g, deg_type=["in", "out"], num_bins="bayes",
                             show=True)



.. image-sg:: /gallery/graph_properties/images/sphx_glr_plot_degrees_003.png
   :alt: Degree distribution for RandomSF
   :srcset: /gallery/graph_properties/images/sphx_glr_plot_degrees_003.png
   :class: sphx-glr-single-img






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

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


.. _sphx_glr_download_gallery_graph_properties_plot_degrees.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_degrees.py <plot_degrees.py>`



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

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


.. only:: html

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

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