diff options
author | jarrodmillman <jarrod.millman@gmail.com> | 2022-12-14 17:21:13 +0000 |
---|---|---|
committer | jarrodmillman <jarrod.millman@gmail.com> | 2022-12-14 17:21:13 +0000 |
commit | 832c558e3507e5cb667a622b5372f91384ab026f (patch) | |
tree | 74481f14ab9cfb5c6984ab59b378cdc857a8180d /_downloads/92c38bebe8b49835778c05efc55350f7 | |
parent | 71985f91c82bf85657dce6a74669e93ec8d29e11 (diff) | |
download | networkx-832c558e3507e5cb667a622b5372f91384ab026f.tar.gz |
Deploying to gh-pages from @ networkx/networkx@6be702047b1bb596a8010cf80911bb6ea939b1d1 🚀
Diffstat (limited to '_downloads/92c38bebe8b49835778c05efc55350f7')
-rw-r--r-- | _downloads/92c38bebe8b49835778c05efc55350f7/plot_basic.ipynb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/_downloads/92c38bebe8b49835778c05efc55350f7/plot_basic.ipynb b/_downloads/92c38bebe8b49835778c05efc55350f7/plot_basic.ipynb new file mode 100644 index 00000000..d3296643 --- /dev/null +++ b/_downloads/92c38bebe8b49835778c05efc55350f7/plot_basic.ipynb @@ -0,0 +1,54 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "%matplotlib inline" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n# Basic matplotlib\n\nA basic example of 3D Graph visualization using `mpl_toolkits.mplot_3d`.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import networkx as nx\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\n\n# The graph to visualize\nG = nx.cycle_graph(20)\n\n# 3d spring layout\npos = nx.spring_layout(G, dim=3, seed=779)\n# Extract node and edge positions from the layout\nnode_xyz = np.array([pos[v] for v in sorted(G)])\nedge_xyz = np.array([(pos[u], pos[v]) for u, v in G.edges()])\n\n# Create the 3D figure\nfig = plt.figure()\nax = fig.add_subplot(111, projection=\"3d\")\n\n# Plot the nodes - alpha is scaled by \"depth\" automatically\nax.scatter(*node_xyz.T, s=100, ec=\"w\")\n\n# Plot the edges\nfor vizedge in edge_xyz:\n ax.plot(*vizedge.T, color=\"tab:gray\")\n\n\ndef _format_axes(ax):\n \"\"\"Visualization options for the 3D axes.\"\"\"\n # Turn gridlines off\n ax.grid(False)\n # Suppress tick labels\n for dim in (ax.xaxis, ax.yaxis, ax.zaxis):\n dim.set_ticks([])\n # Set axes labels\n ax.set_xlabel(\"x\")\n ax.set_ylabel(\"y\")\n ax.set_zlabel(\"z\")\n\n\n_format_axes(ax)\nfig.tight_layout()\nplt.show()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.15" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +}
\ No newline at end of file |