diff --git a/doc/conf.py b/doc/conf.py index 0a25320b16e..2f0abd428ac 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -24,6 +24,8 @@ "nb2plots", "texext", "numpydoc", + "IPython.sphinxext.ipython_directive", + "matplotlib.sphinxext.plot_directive", ] # https://github.com/sphinx-gallery/sphinx-gallery @@ -240,6 +242,36 @@ numpydoc_show_class_members = False +# Make numpydoc to generate plots for example sections +numpydoc_use_plots = True + +plot_pre_code = """ +import networkx as nx +""" + +plot_include_source = True +plot_formats = [("png", 100), "pdf"] + +import math + +phi = (math.sqrt(5) + 1) / 2 + +plot_rcparams = { + "font.size": 8, + "axes.titlesize": 8, + "axes.labelsize": 8, + "xtick.labelsize": 8, + "ytick.labelsize": 8, + "legend.fontsize": 8, + "figure.figsize": (3 * phi, 3), + "figure.subplot.bottom": 0.2, + "figure.subplot.left": 0.2, + "figure.subplot.right": 0.9, + "figure.subplot.top": 0.85, + "figure.subplot.wspace": 0.4, + "text.usetex": False, +} + def setup(app): app.add_css_file("custom.css") diff --git a/networkx/generators/classic.py b/networkx/generators/classic.py index 3fff105f1e1..4815dd448fb 100644 --- a/networkx/generators/classic.py +++ b/networkx/generators/classic.py @@ -274,6 +274,12 @@ def complete_graph(n, create_using=None): >>> G.is_directed() True + $K_5$ with a circular layout + + >>> import matplotlib.pyplot as plt + >>> G = nx.complete_graph(5) + >>> nx.draw_circular(G) + >>> plt.show(); """ _, nodes = n G = empty_graph(nodes, create_using)