~ubuntu-branches/ubuntu/trusty/python-networkx/trusty-proposed

« back to all changes in this revision

Viewing changes to doc/examples/draw_colormap.py

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2009-02-28 13:36:24 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090228133624-9l5rwi1ftlzc7b0l
* Upload to unstable now that lenny is released (yay).
* Fix FTBFS with python-support 0.90.3: no longer rely on its internal
  behaviour, and xnow set tests/test.py executable right after “setup.py
  install” (Closes: #517065).
* Drop executable bits from bz2 files.
* Update Vcs-* fields: move from DPMT's svn to collab-maint's git.
* Remote DPMT from Uploaders, following Piotr Ożarowski's request.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
"""
3
 
Draw a graph with matplotlib, color by degree.
4
 
You must have matplotlib for this to work.
5
 
"""
6
 
__author__ = """Aric Hagberg (hagberg@lanl.gov)"""
7
 
#    Copyright (C) 2004-2006 by 
8
 
#    Aric Hagberg <hagberg@lanl.gov>
9
 
#    Dan Schult <dschult@colgate.edu>
10
 
#    Pieter Swart <swart@lanl.gov>
11
 
#    Distributed under the terms of the GNU Lesser General Public License
12
 
#    http://www.gnu.org/copyleft/lesser.html
13
 
 
14
 
try:
15
 
    from pylab import *
16
 
except:
17
 
    print "pylab not found: see https://networkx.lanl.gov/Drawing.html for info"
18
 
    raise 
19
 
    
20
 
from networkx import *
21
 
 
22
 
G=grid_2d_graph(4,4)  #4x4 grid
23
 
pos=spring_layout(G)
24
 
draw(G,pos,node_color=array([G.degree(v) for v in G]),node_size=800)
25
 
savefig("grid.png") # save as png
26
 
show() # display