summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authoraric <none@none>2010-03-06 17:40:33 +0000
committeraric <none@none>2010-03-06 17:40:33 +0000
commit15d6627903c8e4c9879c0f09f8a3f1cb9edfed5d (patch)
tree4279d407a4d550b1ee871ff4dee95618b02ae8c1 /examples
parent75fc4d95d7d4312f3ca4c7cbed8b8d9d68abbbcd (diff)
downloadnetworkx-15d6627903c8e4c9879c0f09f8a3f1cb9edfed5d.tar.gz
Sampson's example
--HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401547
Diffstat (limited to 'examples')
-rw-r--r--examples/drawing/sampson.py46
-rw-r--r--examples/drawing/sampson_data.zipbin0 -> 976 bytes
2 files changed, 46 insertions, 0 deletions
diff --git a/examples/drawing/sampson.py b/examples/drawing/sampson.py
new file mode 100644
index 00000000..b1e9b072
--- /dev/null
+++ b/examples/drawing/sampson.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+"""
+Sampson's monastery data.
+
+Shows how to read data from a zip file and plot multiple frames.
+
+"""
+__author__ = """Aric Hagberg (hagberg@lanl.gov)"""
+# Copyright (C) 2010 by
+# Aric Hagberg <hagberg@lanl.gov>
+# Dan Schult <dschult@colgate.edu>
+# Pieter Swart <swart@lanl.gov>
+# All rights reserved.
+# BSD license.
+
+import zipfile
+import networkx as nx
+import matplotlib.pyplot as plt
+
+zf = zipfile.ZipFile('sampson_data.zip') # zipfile object
+e1=zf.open('samplike1.txt') # read info file
+e2=zf.open('samplike2.txt') # read info file
+e3=zf.open('samplike3.txt') # read info file
+G1=nx.read_edgelist(e1,delimiter='\t')
+G2=nx.read_edgelist(e2,delimiter='\t')
+G3=nx.read_edgelist(e3,delimiter='\t')
+pos=nx.spring_layout(G3,iterations=100)
+plt.clf()
+
+plt.subplot(221)
+plt.title('samplike1')
+nx.draw(G1,pos,node_size=50,with_labels=False)
+plt.subplot(222)
+plt.title('samplike2')
+nx.draw(G2,pos,node_size=50,with_labels=False)
+plt.subplot(223)
+plt.title('samplike3')
+nx.draw(G3,pos,node_size=50,with_labels=False)
+plt.subplot(224)
+plt.title('samplike1,2,3')
+nx.draw(G3,pos,edgelist=G3.edges(),node_size=50,with_labels=False)
+nx.draw_networkx_edges(G1,pos,alpha=0.25)
+nx.draw_networkx_edges(G2,pos,alpha=0.25)
+plt.savefig("sampson.png") # save as png
+plt.show() # display
+
diff --git a/examples/drawing/sampson_data.zip b/examples/drawing/sampson_data.zip
new file mode 100644
index 00000000..2a72b375
--- /dev/null
+++ b/examples/drawing/sampson_data.zip
Binary files differ