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