|
1 | 1 | import matplotlib.pyplot as plt
|
2 | 2 | import numpy as np
|
3 |
| -from matplotlib.ticker import OldScalarFormatter, ScalarFormatter |
4 |
| - |
5 |
| -# Example 1 |
6 |
| -x = np.arange(0, 1, .01) |
7 |
| -fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2, figsize=(6, 6)) |
8 |
| -fig.text(0.5, 0.975, 'The old formatter', |
9 |
| - horizontalalignment='center', verticalalignment='top') |
10 |
| -ax1.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5) |
11 |
| -ax1.xaxis.set_major_formatter(OldScalarFormatter()) |
12 |
| -ax1.yaxis.set_major_formatter(OldScalarFormatter()) |
13 |
| - |
14 |
| -ax2.plot(x * 1e5, x * 1e-4) |
15 |
| -ax2.xaxis.set_major_formatter(OldScalarFormatter()) |
16 |
| -ax2.yaxis.set_major_formatter(OldScalarFormatter()) |
17 |
| - |
18 |
| -ax3.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10) |
19 |
| -ax3.xaxis.set_major_formatter(OldScalarFormatter()) |
20 |
| -ax3.yaxis.set_major_formatter(OldScalarFormatter()) |
21 |
| - |
22 |
| -ax4.plot(-x * 1e5, -x * 1e-4) |
23 |
| -ax4.xaxis.set_major_formatter(OldScalarFormatter()) |
24 |
| -ax4.yaxis.set_major_formatter(OldScalarFormatter()) |
| 3 | +from matplotlib.ticker import ScalarFormatter |
25 | 4 |
|
26 | 5 | # Example 2
|
27 | 6 | x = np.arange(0, 1, .01)
|
|
54 | 33 | verticalalignment='top')
|
55 | 34 |
|
56 | 35 | ax1.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5)
|
57 |
| -ax1.xaxis.set_major_formatter(ScalarFormatter(useOffset=False)) |
58 |
| -ax1.yaxis.set_major_formatter(ScalarFormatter(useOffset=False)) |
| 36 | +ax1.xaxis.set_major_formatter(ScalarFormatter(use_offset=False)) |
| 37 | +ax1.yaxis.set_major_formatter(ScalarFormatter(use_offset=False)) |
59 | 38 |
|
60 | 39 | ax2.plot(x * 1e5, x * 1e-4)
|
61 |
| -ax2.xaxis.set_major_formatter(ScalarFormatter(useOffset=False)) |
62 |
| -ax2.yaxis.set_major_formatter(ScalarFormatter(useOffset=False)) |
| 40 | +ax2.xaxis.set_major_formatter(ScalarFormatter(use_offset=False)) |
| 41 | +ax2.yaxis.set_major_formatter(ScalarFormatter(use_offset=False)) |
63 | 42 |
|
64 | 43 | ax3.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10)
|
65 |
| -ax3.xaxis.set_major_formatter(ScalarFormatter(useOffset=False)) |
66 |
| -ax3.yaxis.set_major_formatter(ScalarFormatter(useOffset=False)) |
| 44 | +ax3.xaxis.set_major_formatter(ScalarFormatter(use_offset=False)) |
| 45 | +ax3.yaxis.set_major_formatter(ScalarFormatter(use_offset=False)) |
67 | 46 |
|
68 | 47 | ax4.plot(-x * 1e5, -x * 1e-4)
|
69 |
| -ax4.xaxis.set_major_formatter(ScalarFormatter(useOffset=False)) |
70 |
| -ax4.yaxis.set_major_formatter(ScalarFormatter(useOffset=False)) |
| 48 | +ax4.xaxis.set_major_formatter(ScalarFormatter(use_offset=False)) |
| 49 | +ax4.yaxis.set_major_formatter(ScalarFormatter(use_offset=False)) |
71 | 50 |
|
72 | 51 | # Example 4
|
73 | 52 | x = np.arange(0, 1, .01)
|
|
77 | 56 | verticalalignment='top')
|
78 | 57 |
|
79 | 58 | ax1.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5)
|
80 |
| -ax1.xaxis.set_major_formatter(ScalarFormatter(useMathText=True)) |
81 |
| -ax1.yaxis.set_major_formatter(ScalarFormatter(useMathText=True)) |
| 59 | +ax1.xaxis.set_major_formatter(ScalarFormatter(use_mathtext=True)) |
| 60 | +ax1.yaxis.set_major_formatter(ScalarFormatter(use_mathtext=True)) |
82 | 61 |
|
83 | 62 | ax2.plot(x * 1e5, x * 1e-4)
|
84 |
| -ax2.xaxis.set_major_formatter(ScalarFormatter(useMathText=True)) |
85 |
| -ax2.yaxis.set_major_formatter(ScalarFormatter(useMathText=True)) |
| 63 | +ax2.xaxis.set_major_formatter(ScalarFormatter(use_mathtext=True)) |
| 64 | +ax2.yaxis.set_major_formatter(ScalarFormatter(use_mathtext=True)) |
86 | 65 |
|
87 | 66 | ax3.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10)
|
88 |
| -ax3.xaxis.set_major_formatter(ScalarFormatter(useMathText=True)) |
89 |
| -ax3.yaxis.set_major_formatter(ScalarFormatter(useMathText=True)) |
| 67 | +ax3.xaxis.set_major_formatter(ScalarFormatter(use_mathtext=True)) |
| 68 | +ax3.yaxis.set_major_formatter(ScalarFormatter(use_mathtext=True)) |
90 | 69 |
|
91 | 70 | ax4.plot(-x * 1e5, -x * 1e-4)
|
92 |
| -ax4.xaxis.set_major_formatter(ScalarFormatter(useMathText=True)) |
93 |
| -ax4.yaxis.set_major_formatter(ScalarFormatter(useMathText=True)) |
| 71 | +ax4.xaxis.set_major_formatter(ScalarFormatter(use_mathtext=True)) |
| 72 | +ax4.yaxis.set_major_formatter(ScalarFormatter(use_mathtext=True)) |
94 | 73 | plt.show()
|
0 commit comments