|
2 | 2 | import numpy as np
|
3 | 3 | from matplotlib.ticker import OldScalarFormatter, ScalarFormatter
|
4 | 4 |
|
5 |
| -## Example 1 ## |
| 5 | +# Example 1 |
6 | 6 | x = np.arange(0, 1, .01)
|
7 | 7 | fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2, figsize=(6, 6))
|
8 | 8 | fig.text(0.5, 0.975, 'The old formatter',
|
9 |
| - horizontalalignment='center', verticalalignment='top') |
| 9 | + horizontalalignment='center', verticalalignment='top') |
10 | 10 | ax1.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5)
|
11 | 11 | ax1.xaxis.set_major_formatter(OldScalarFormatter())
|
12 | 12 | ax1.yaxis.set_major_formatter(OldScalarFormatter())
|
|
24 | 24 | ax4.xaxis.set_major_formatter(OldScalarFormatter())
|
25 | 25 | ax4.yaxis.set_major_formatter(OldScalarFormatter())
|
26 | 26 |
|
27 |
| -## Example 2 ## |
| 27 | +# Example 2 |
28 | 28 | x = np.arange(0, 1, .01)
|
29 | 29 | fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2, figsize=(6, 6))
|
30 | 30 | fig.text(0.5, 0.975, 'The new formatter, default settings',
|
31 |
| - horizontalalignment='center', |
32 |
| - verticalalignment='top') |
| 31 | + horizontalalignment='center', |
| 32 | + verticalalignment='top') |
33 | 33 |
|
34 | 34 | ax1.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5)
|
35 | 35 | ax1.xaxis.set_major_formatter(ScalarFormatter())
|
|
47 | 47 | ax4.xaxis.set_major_formatter(ScalarFormatter())
|
48 | 48 | ax4.yaxis.set_major_formatter(ScalarFormatter())
|
49 | 49 |
|
50 |
| -## Example 3 ## |
| 50 | +# Example 3 |
51 | 51 | x = np.arange(0, 1, .01)
|
52 | 52 | fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2, figsize=(6, 6))
|
53 | 53 | fig.text(0.5, 0.975, 'The new formatter, no numerical offset',
|
54 |
| - horizontalalignment='center', |
55 |
| - verticalalignment='top') |
| 54 | + horizontalalignment='center', |
| 55 | + verticalalignment='top') |
56 | 56 |
|
57 | 57 | ax1.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5)
|
58 | 58 | ax1.xaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
|
70 | 70 | ax4.xaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
71 | 71 | ax4.yaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
72 | 72 |
|
73 |
| -## Example 4 ## |
| 73 | +# Example 4 |
74 | 74 | x = np.arange(0, 1, .01)
|
75 | 75 | fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2, figsize=(6, 6))
|
76 | 76 | fig.text(0.5, 0.975, 'The new formatter, with mathtext',
|
77 |
| - horizontalalignment='center', |
78 |
| - verticalalignment='top') |
| 77 | + horizontalalignment='center', |
| 78 | + verticalalignment='top') |
79 | 79 |
|
80 | 80 | ax1.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5)
|
81 | 81 | ax1.xaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
|
0 commit comments