diff options
author | Ross Barnowski <rossbar@berkeley.edu> | 2020-11-14 16:45:38 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-14 16:45:38 -0800 |
commit | a00d1b4e358df0b238ccb60a2d7bb6b74717a1ef (patch) | |
tree | bcc994ef00d52a37ac45c13d6879e77246e41d86 /examples/3d_drawing | |
parent | 457ab82bda75fad7f096a170b7d80dd7f295dee5 (diff) | |
download | networkx-a00d1b4e358df0b238ccb60a2d7bb6b74717a1ef.tar.gz |
Enable mayavi in sphinx gallery. (#4297)
* Enable mayavi in sphinx gallery.
* Add mayavi deps to example requirements.
* Install vtk before mayavi
* Don't popup Mayavi windows
* Display offscreen
* Borrow mayavi CI conf from sphinx-gallery
* Grab dependencies as specified in sphinx-gallery conf.
* Set up virtual frame buffer so mayavi can import/run headless.
Co-authored-by: Jarrod Millman <jarrod.millman@gmail.com>
Diffstat (limited to 'examples/3d_drawing')
-rw-r--r-- | examples/3d_drawing/plot_mayavi2_spring.py (renamed from examples/3d_drawing/mayavi2_spring.py) | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/3d_drawing/mayavi2_spring.py b/examples/3d_drawing/plot_mayavi2_spring.py index 7aa0b30a..bec09694 100644 --- a/examples/3d_drawing/mayavi2_spring.py +++ b/examples/3d_drawing/plot_mayavi2_spring.py @@ -18,12 +18,14 @@ H = nx.cycle_graph(20) # reorder nodes from 0,len(G)-1 G = nx.convert_node_labels_to_integers(H) # 3d spring layout -pos = nx.spring_layout(G, dim=3) +pos = nx.spring_layout(G, dim=3, seed=1001) # numpy array of x,y,z positions in sorted node order xyz = np.array([pos[v] for v in sorted(G)]) # scalar colors scalars = np.array(list(G.nodes())) + 5 +mlab.figure() + pts = mlab.points3d( xyz[:, 0], xyz[:, 1], @@ -38,4 +40,4 @@ pts = mlab.points3d( pts.mlab_source.dataset.lines = np.array(list(G.edges())) tube = mlab.pipeline.tube(pts, tube_radius=0.01) mlab.pipeline.surface(tube, color=(0.8, 0.8, 0.8)) -mlab.show() +mlab.orientation_axes() |