|
1 | 1 | from pylab import figure, show, nx |
2 | 2 |
|
| 3 | +Ntests = 3 |
| 4 | +t = nx.arange(0.0, 1.0, 0.05) |
| 5 | +s = nx.sin(2*nx.pi*t) |
| 6 | + |
3 | 7 | # scatter creates a RegPolyCollection |
4 | 8 | fig = figure() |
5 | | -ax = fig.add_subplot(111) |
| 9 | +ax = fig.add_subplot(Ntests, 1, 1) |
6 | 10 | N = 100 |
7 | 11 | x, y = 0.9*nx.mlab.rand(2,N) |
8 | 12 | area = nx.pi*(10 * nx.mlab.rand(N))**2 # 0 to 10 point radiuses |
9 | 13 | ax.scatter(x,y,s=area, marker='^', c='r', label='scatter') |
10 | 14 | ax.legend() |
11 | | -fig.savefig('legend_unit_polycoll') |
12 | 15 |
|
13 | 16 | # vlines creates a LineCollection |
14 | | -fig = figure() |
15 | | -ax = fig.add_subplot(111) |
16 | | -t = nx.arange(0.0, 1.0, 0.05) |
| 17 | +ax = fig.add_subplot(Ntests, 1, 2) |
17 | 18 | ax.vlines(t, [0], nx.sin(2*nx.pi*t), label='vlines') |
18 | 19 | ax.legend() |
19 | | -fig.savefig('legend_unit_linecoll') |
| 20 | + |
| 21 | +# vlines creates a LineCollection |
| 22 | +ax = fig.add_subplot(Ntests, 1, 3) |
| 23 | +ax.plot(t, s, 'b-', lw=2, label='a line') |
| 24 | +ax.legend() |
| 25 | + |
| 26 | +fig.savefig('legend_unit') |
20 | 27 | show() |
0 commit comments