Statistics
| Branch: | Revision:

iof-tools / networkxMiCe / networkx-master / examples / drawing / plot_house_with_colors.py @ 5cef0f13

History | View | Annotate | Download (623 Bytes)

1
#!/usr/bin/env python
2
"""
3
=================
4
House With Colors
5
=================
6

7
Draw a graph with matplotlib.
8
You must have matplotlib for this to work.
9
"""
10
# Author: Aric Hagberg (hagberg@lanl.gov)
11
import matplotlib.pyplot as plt
12
import networkx as nx
13

    
14
G = nx.house_graph()
15
# explicitly set positions
16
pos = {0: (0, 0),
17
       1: (1, 0),
18
       2: (0, 1),
19
       3: (1, 1),
20
       4: (0.5, 2.0)}
21

    
22
nx.draw_networkx_nodes(G, pos, node_size=2000, nodelist=[4])
23
nx.draw_networkx_nodes(G, pos, node_size=3000, nodelist=[0, 1, 2, 3], node_color='b')
24
nx.draw_networkx_edges(G, pos, alpha=0.5, width=6)
25
plt.axis('off')
26
plt.show()