| 726 | return fig |
| 727 | |
| 728 | def PyplotScales(): |
| 729 | import numpy as np |
| 730 | import matplotlib.pyplot as plt |
| 731 | |
| 732 | from matplotlib.ticker import NullFormatter # useful for `logit` scale |
| 733 | |
| 734 | # Fixing random state for reproducibility |
| 735 | np.random.seed(19680801) |
| 736 | |
| 737 | # make up some data in the interval ]0, 1[ |
| 738 | y = np.random.normal(loc=0.5, scale=0.4, size=1000) |
| 739 | y = y[(y > 0) & (y < 1)] |
| 740 | y.sort() |
| 741 | x = np.arange(len(y)) |
| 742 | |
| 743 | # plot with various axes scales |
| 744 | plt.figure(1) |
| 745 | |
| 746 | # linear |
| 747 | plt.subplot(221) |
| 748 | plt.plot(x, y) |
| 749 | plt.yscale('linear') |
| 750 | plt.title('linear') |
| 751 | plt.grid(True) |
| 752 | |
| 753 | # log |
| 754 | plt.subplot(222) |
| 755 | plt.plot(x, y) |
| 756 | plt.yscale('log') |
| 757 | plt.title('log') |
| 758 | plt.grid(True) |
| 759 | |
| 760 | # symmetric log |
| 761 | plt.subplot(223) |
| 762 | plt.plot(x, y - y.mean()) |
| 763 | plt.yscale('symlog', linthreshy=0.01) |
| 764 | plt.title('symlog') |
| 765 | plt.grid(True) |
| 766 | |
| 767 | # logit |
| 768 | plt.subplot(224) |
| 769 | plt.plot(x, y) |
| 770 | plt.yscale('logit') |
| 771 | plt.title('logit') |
| 772 | plt.grid(True) |
| 773 | # Format the minor tick labels of the y-axis into empty strings with |
| 774 | # `NullFormatter`, to avoid cumbering the axis with too many labels. |
| 775 | plt.gca().yaxis.set_minor_formatter(NullFormatter()) |
| 776 | # Adjust the subplot layout, because the logit one may take more space |
| 777 | # than usual, due to y-tick labels like "1 - 10^{-3}" |
| 778 | plt.subplots_adjust(top=0.92, bottom=0.08, left=0.10, right=0.95, hspace=0.25, |
| 779 | wspace=0.35) |
| 780 | return plt.gcf() |
| 781 | |
| 782 | |
| 783 | def AxesGrid(): |