source: orange/orange/doc/Orange/rst/code/network-read.py @ 7768:ec9a34c8739a

Revision 7768:ec9a34c8739a, 473 bytes checked in by miha <miha.stajdohar@…>, 3 years ago (diff)

Changed from pylab import * to from matplotlib import pyplot as plt.
Save image to file instead of opening a pylab widget.

Line 
1import Orange.network
2
3from matplotlib import pyplot as plt
4
5# read network from file
6net = Orange.network.Network.read("K5.net")
7
8# read all edges and plot a line
9for u, v in net.getEdges():
10    x1, y1 = net.coors[0][u], net.coors[1][u]
11    x2, y2 = net.coors[0][v], net.coors[1][v]
12    plt.plot([x1, x2], [y1, y2], 'b-')
13
14# read x and y coordinates to Python list
15x = net.coors[0]
16y = net.coors[1]
17
18# plot vertices
19plt.plot(x, y, 'ro')
20plt.savefig("network-read.py.png")
Note: See TracBrowser for help on using the repository browser.