| 639 | return fig |
| 640 | |
| 641 | def ExploringNormalizations(): |
| 642 | import matplotlib.pyplot as plt |
| 643 | import matplotlib.colors as mcolors |
| 644 | import numpy as np |
| 645 | from numpy.random import multivariate_normal |
| 646 | |
| 647 | data = np.vstack([ |
| 648 | multivariate_normal([10, 10], [[3, 2], [2, 3]], size=100000), |
| 649 | multivariate_normal([30, 20], [[2, 3], [1, 3]], size=1000) |
| 650 | ]) |
| 651 | |
| 652 | gammas = [0.8, 0.5, 0.3] |
| 653 | |
| 654 | fig, axes = plt.subplots(nrows=2, ncols=2) |
| 655 | |
| 656 | axes[0, 0].set_title('Linear normalization') |
| 657 | axes[0, 0].hist2d(data[:, 0], data[:, 1], bins=100) |
| 658 | |
| 659 | for ax, gamma in zip(axes.flat[1:], gammas): |
| 660 | ax.set_title(r'Power law $(\gamma=%1.1f)$' % gamma) |
| 661 | ax.hist2d(data[:, 0], data[:, 1], |
| 662 | bins=100, norm=mcolors.PowerNorm(gamma)) |
| 663 | |
| 664 | fig.tight_layout() |
| 665 | return fig |
| 666 | |
| 667 | def PyplotFormatstr(): |
| 668 | |