.. 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 :ref:`Go to the end ` 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 10-26 .. code-block:: Python 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 27-28 First, let's create a scale-free network .. GENERATED FROM PYTHON SOURCE LINES 28-32 .. code-block:: Python g = nngt.generation.random_scale_free(2.1, 3.2, nodes=1000, avg_deg=100) .. GENERATED FROM PYTHON SOURCE LINES 33-34 Plot the degree distribution .. GENERATED FROM PYTHON SOURCE LINES 34-37 .. code-block:: Python 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 38-39 It's not bad... but we don't see much! Let's move a more relevant scale .. GENERATED FROM PYTHON SOURCE LINES 39-43 .. code-block:: Python 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 44-45 Or we can use Bayesian binning .. GENERATED FROM PYTHON SOURCE LINES 45-48 .. code-block:: Python 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 1.077 seconds) .. _sphx_glr_download_gallery_graph_properties_plot_degrees.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_degrees.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_degrees.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_