|
4 | 4 |
|
5 | 5 | ## Example 1 ##
|
6 | 6 | x = np.arange(0, 1, .01)
|
7 |
| -f = plt.figure(figsize=(6, 6)) |
8 |
| -f.text(0.5, 0.975, 'The old formatter', |
| 7 | +fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2, figsize=(6, 6)) |
| 8 | +fig.text(0.5, 0.975, 'The old formatter', |
9 | 9 | horizontalalignment='center', verticalalignment='top')
|
10 |
| - |
11 |
| -plt.subplot(221) |
12 |
| -plt.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5) |
13 |
| -ax1 = plt.gca() |
| 10 | +ax1.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5) |
14 | 11 | ax1.xaxis.set_major_formatter(OldScalarFormatter())
|
15 | 12 | ax1.yaxis.set_major_formatter(OldScalarFormatter())
|
16 | 13 |
|
17 |
| -plt.subplot(222) |
18 |
| -plt.plot(x * 1e5, x * 1e-4) |
19 |
| -ax2 = plt.gca() |
| 14 | +ax2.plot(x * 1e5, x * 1e-4) |
20 | 15 | ax2.xaxis.set_major_formatter(OldScalarFormatter())
|
21 | 16 | ax2.yaxis.set_major_formatter(OldScalarFormatter())
|
22 | 17 |
|
23 |
| -plt.subplot(223) |
24 |
| -plt.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10) |
25 |
| -ax3 = plt.gca() |
| 18 | +ax3.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10) |
26 | 19 | ax3.xaxis.set_major_formatter(OldScalarFormatter())
|
27 | 20 | ax3.yaxis.set_major_formatter(OldScalarFormatter())
|
28 | 21 |
|
29 |
| -plt.subplot(224) |
30 |
| -plt.plot(-x * 1e5, -x * 1e-4) |
| 22 | +ax4.plot(-x * 1e5, -x * 1e-4) |
31 | 23 | ax4 = plt.gca()
|
32 | 24 | ax4.xaxis.set_major_formatter(OldScalarFormatter())
|
33 | 25 | ax4.yaxis.set_major_formatter(OldScalarFormatter())
|
34 | 26 |
|
35 | 27 | ## Example 2 ##
|
36 | 28 | x = np.arange(0, 1, .01)
|
37 |
| -f = plt.figure(figsize=(6, 6)) |
38 |
| -f.text(0.5, 0.975, 'The new formatter, default settings', |
| 29 | +fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2, figsize=(6, 6)) |
| 30 | +fig.text(0.5, 0.975, 'The new formatter, default settings', |
39 | 31 | horizontalalignment='center',
|
40 | 32 | verticalalignment='top')
|
41 | 33 |
|
42 |
| -plt.subplot(221) |
43 |
| -plt.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5) |
44 |
| -ax1 = plt.gca() |
| 34 | +ax1.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5) |
45 | 35 | ax1.xaxis.set_major_formatter(ScalarFormatter())
|
46 | 36 | ax1.yaxis.set_major_formatter(ScalarFormatter())
|
47 | 37 |
|
48 |
| -plt.subplot(222) |
49 |
| -plt.plot(x * 1e5, x * 1e-4) |
50 |
| -ax2 = plt.gca() |
| 38 | +ax2.plot(x * 1e5, x * 1e-4) |
51 | 39 | ax2.xaxis.set_major_formatter(ScalarFormatter())
|
52 | 40 | ax2.yaxis.set_major_formatter(ScalarFormatter())
|
53 | 41 |
|
54 |
| -plt.subplot(223) |
55 |
| -plt.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10) |
56 |
| -ax3 = plt.gca() |
| 42 | +ax3.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10) |
57 | 43 | ax3.xaxis.set_major_formatter(ScalarFormatter())
|
58 | 44 | ax3.yaxis.set_major_formatter(ScalarFormatter())
|
59 | 45 |
|
60 |
| -plt.subplot(224) |
61 |
| -plt.plot(-x * 1e5, -x * 1e-4) |
62 |
| -ax4 = plt.gca() |
| 46 | +ax4.plot(-x * 1e5, -x * 1e-4) |
63 | 47 | ax4.xaxis.set_major_formatter(ScalarFormatter())
|
64 | 48 | ax4.yaxis.set_major_formatter(ScalarFormatter())
|
65 | 49 |
|
66 | 50 | ## Example 3 ##
|
67 | 51 | x = np.arange(0, 1, .01)
|
68 |
| -f = plt.figure(figsize=(6, 6)) |
69 |
| -f.text(0.5, 0.975, 'The new formatter, no numerical offset', |
| 52 | +fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2, figsize=(6, 6)) |
| 53 | +fig.text(0.5, 0.975, 'The new formatter, no numerical offset', |
70 | 54 | horizontalalignment='center',
|
71 | 55 | verticalalignment='top')
|
72 | 56 |
|
73 |
| -plt.subplot(221) |
74 |
| -plt.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5) |
75 |
| -ax1 = plt.gca() |
| 57 | +ax1.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5) |
76 | 58 | ax1.xaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
77 | 59 | ax1.yaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
78 | 60 |
|
79 |
| -plt.subplot(222) |
80 |
| -plt.plot(x * 1e5, x * 1e-4) |
81 |
| -ax2 = plt.gca() |
| 61 | +ax2.plot(x * 1e5, x * 1e-4) |
82 | 62 | ax2.xaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
83 | 63 | ax2.yaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
84 | 64 |
|
85 |
| -plt.subplot(223) |
86 |
| -plt.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10) |
87 |
| -ax3 = plt.gca() |
| 65 | +ax3.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10) |
88 | 66 | ax3.xaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
89 | 67 | ax3.yaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
90 | 68 |
|
91 |
| -plt.subplot(224) |
92 |
| -plt.plot(-x * 1e5, -x * 1e-4) |
93 |
| -ax4 = plt.gca() |
| 69 | +ax4.plot(-x * 1e5, -x * 1e-4) |
94 | 70 | ax4.xaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
95 | 71 | ax4.yaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
96 | 72 |
|
97 | 73 | ## Example 4 ##
|
98 | 74 | x = np.arange(0, 1, .01)
|
99 |
| -f = plt.figure(figsize=(6, 6)) |
100 |
| -f.text(0.5, 0.975, 'The new formatter, with mathtext', |
| 75 | +fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2, figsize=(6, 6)) |
| 76 | +fig.text(0.5, 0.975, 'The new formatter, with mathtext', |
101 | 77 | horizontalalignment='center',
|
102 | 78 | verticalalignment='top')
|
103 |
| -plt.subplot(221) |
104 |
| -plt.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5) |
105 |
| -ax1 = plt.gca() |
| 79 | + |
| 80 | +ax1.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5) |
106 | 81 | ax1.xaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
107 | 82 | ax1.yaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
108 | 83 |
|
109 |
| -plt.subplot(222) |
110 |
| -plt.plot(x * 1e5, x * 1e-4) |
111 |
| -ax2 = plt.gca() |
| 84 | +ax2.plot(x * 1e5, x * 1e-4) |
112 | 85 | ax2.xaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
113 | 86 | ax2.yaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
114 | 87 |
|
115 |
| -plt.subplot(223) |
116 |
| -plt.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10) |
117 |
| -ax3 = plt.gca() |
| 88 | +ax3.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10) |
118 | 89 | ax3.xaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
119 | 90 | ax3.yaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
120 | 91 |
|
121 |
| -plt.subplot(224) |
122 |
| -plt.plot(-x * 1e5, -x * 1e-4) |
123 |
| -ax4 = plt.gca() |
| 92 | +ax4.plot(-x * 1e5, -x * 1e-4) |
124 | 93 | ax4.xaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
125 | 94 | ax4.yaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
126 | 95 | plt.show()
|
0 commit comments