|
1 | 1 | #!/usr/bin/python |
2 | 2 |
|
3 | | -from scipy.stats import norm |
4 | | -from matplotlib import pyplot as pl |
| 3 | +from matplotlib import pyplot as plt |
5 | 4 | import matplotlib.colors as mcolors |
6 | 5 | import numpy as np |
7 | 6 | from numpy.random import multivariate_normal |
8 | 7 |
|
9 | | -samples = np.vstack([ multivariate_normal([10,10], [[3,5],[4,2]], size=100000), |
10 | | - multivariate_normal([30,20], [[2,3],[1,3]], size=1000) |
| 8 | +samples = np.vstack([multivariate_normal([10, 10], [[3, 5],[4, 2]], size=100000), |
| 9 | + multivariate_normal([30, 20], [[2, 3],[1, 3]], size=1000) |
11 | 10 | ]) |
12 | 11 |
|
13 | 12 | gammas = [0.8, 0.5, 0.3] |
14 | | -xgrid = np.floor((len(gammas)+1.)/2) |
15 | | -ygrid = np.ceil((len(gammas)+1.)/2) |
| 13 | +xgrid = np.floor((len(gammas) + 1.) / 2) |
| 14 | +ygrid = np.ceil((len(gammas) + 1.) / 2) |
16 | 15 |
|
17 | | -pl.subplot(xgrid, ygrid, 1) |
18 | | -pl.title('Linear normalization') |
19 | | -pl.hist2d(samples[:,0], samples[:,1], bins=100) |
| 16 | +plt.subplot(xgrid, ygrid, 1) |
| 17 | +plt.title('Linear normalization') |
| 18 | +plt.hist2d(samples[:,0], samples[:,1], bins=100) |
20 | 19 |
|
21 | | -for i,gamma in enumerate(gammas): |
22 | | - pl.subplot(xgrid, ygrid, i+2) |
23 | | - pl.title('Power law normalization\n$(\gamma=%1.1f)$' % gamma) |
24 | | - pl.hist2d(samples[:,0], samples[:,1], bins=100, norm=mcolors.PowerNorm(gamma)) |
| 20 | +for i, gamma in enumerate(gammas): |
| 21 | + plt.subplot(xgrid, ygrid, i + 2) |
| 22 | + plt.title('Power law normalization\n$(\gamma=%1.1f)$' % gamma) |
| 23 | + plt.hist2d(samples[:, 0], samples[:, 1], |
| 24 | + bins=100, norm=mcolors.PowerNorm(gamma)) |
25 | 25 |
|
26 | | -pl.subplots_adjust(hspace=0.39) |
27 | | -pl.show() |
| 26 | +plt.subplots_adjust(hspace=0.39) |
| 27 | +plt.show() |
0 commit comments