|
1 | 1 | # from pylab import *
|
2 |
| -import matplotlib.pyplot as plt |
3 |
| -import numpy as np |
| 2 | +import matplotlib.pyplot as plt |
| 3 | +import numpy as np |
4 | 4 | from matplotlib.ticker import OldScalarFormatter, ScalarFormatter
|
5 | 5 |
|
6 | 6 | x = np.arange(0, 1, .01)
|
7 | 7 | f = plt.figure(figsize=(6, 6))
|
8 |
| -f.text(0.5, 0.975, 'The old formatter', horizontalalignment='center', verticalalignment='top') |
| 8 | +f.text(0.5, 0.975, 'The old formatter', |
| 9 | + horizontalalignment='center', verticalalignment='top') |
9 | 10 | plt.subplot(221)
|
10 |
| -plt.plot(x*1e5 + 1e10, x*1e-10 + 1e-5) |
| 11 | +plt.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5) |
11 | 12 | plt.gca().xaxis.set_major_formatter(OldScalarFormatter())
|
12 | 13 | plt.gca().yaxis.set_major_formatter(OldScalarFormatter())
|
13 | 14 | plt.subplot(222)
|
14 |
| -plt.plot(x*1e5, x*1e-4) |
| 15 | +plt.plot(x * 1e5, x * 1e-4) |
15 | 16 | plt.gca().xaxis.set_major_formatter(OldScalarFormatter())
|
16 | 17 | plt.gca().yaxis.set_major_formatter(OldScalarFormatter())
|
17 | 18 | plt.subplot(223)
|
18 |
| -plt.plot(-x*1e5 - 1e10, -x*1e-5 - 1e-10) |
| 19 | +plt.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10) |
19 | 20 | plt.gca().xaxis.set_major_formatter(OldScalarFormatter())
|
20 | 21 | plt.gca().yaxis.set_major_formatter(OldScalarFormatter())
|
21 | 22 | plt.subplot(224)
|
22 |
| -plt.plot(-x*1e5, -x*1e-4) |
| 23 | +plt.plot(-x * 1e5, -x * 1e-4) |
23 | 24 | plt.gca().xaxis.set_major_formatter(OldScalarFormatter())
|
24 | 25 | plt.gca().yaxis.set_major_formatter(OldScalarFormatter())
|
25 | 26 |
|
26 | 27 | x = np.arange(0, 1, .01)
|
27 | 28 | f = figure(figsize=(6, 6))
|
28 |
| -f.text(0.5, 0.975, 'The new formatter, default settings', horizontalalignment='center', |
| 29 | +f.text(0.5, 0.975, 'The new formatter, default settings', |
| 30 | + horizontalalignment='center', |
29 | 31 | verticalalignment='top')
|
30 | 32 | plt.subplot(221)
|
31 |
| -plt.plot(x*1e5 + 1e10, x*1e-10 + 1e-5) |
| 33 | +plt.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5) |
32 | 34 | plt.gca().xaxis.set_major_formatter(ScalarFormatter())
|
33 | 35 | plt.gca().yaxis.set_major_formatter(ScalarFormatter())
|
34 | 36 | plt.subplot(222)
|
35 |
| -plt.plot(x*1e5, x*1e-4) |
| 37 | +plt.plot(x * 1e5, x * 1e-4) |
36 | 38 | plt.gca().xaxis.set_major_formatter(ScalarFormatter())
|
37 | 39 | plt.gca().yaxis.set_major_formatter(ScalarFormatter())
|
38 | 40 | plt.subplot(223)
|
39 |
| -plt.plot(-x*1e5 - 1e10, -x*1e-5 - 1e-10) |
| 41 | +plt.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10) |
40 | 42 | plt.gca().xaxis.set_major_formatter(ScalarFormatter())
|
41 | 43 | plt.gca().yaxis.set_major_formatter(ScalarFormatter())
|
42 | 44 | plt.subplot(224)
|
43 |
| -plt.plot(-x*1e5, -x*1e-4) |
| 45 | +plt.plot(-x * 1e5, -x * 1e-4) |
44 | 46 | plt.gca().xaxis.set_major_formatter(ScalarFormatter())
|
45 | 47 | plt.gca().yaxis.set_major_formatter(ScalarFormatter())
|
46 | 48 |
|
47 | 49 | x = np.arange(0, 1, .01)
|
48 | 50 | f = figure(figsize=(6, 6))
|
49 |
| -f.text(0.5, 0.975, 'The new formatter, no numerical offset', horizontalalignment='center', |
| 51 | +f.text(0.5, 0.975, 'The new formatter, no numerical offset', |
| 52 | + horizontalalignment='center', |
50 | 53 | verticalalignment='top')
|
51 | 54 | plt.subplot(221)
|
52 |
| -plt.plot(x*1e5 + 1e10, x*1e-10 + 1e-5) |
| 55 | +plt.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5) |
53 | 56 | plt.gca().xaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
54 | 57 | plt.gca().yaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
55 | 58 | plt.subplot(222)
|
56 |
| -plt.plot(x*1e5, x*1e-4) |
| 59 | +plt.plot(x * 1e5, x * 1e-4) |
57 | 60 | plt.gca().xaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
58 | 61 | plt.gca().yaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
59 | 62 | plt.subplot(223)
|
60 |
| -plt.plot(-x*1e5 - 1e10, -x*1e-5 - 1e-10) |
| 63 | +plt.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10) |
61 | 64 | plt.gca().xaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
62 | 65 | plt.gca().yaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
63 | 66 | plt.subplot(224)
|
64 |
| -plt.plot(-x*1e5, -x*1e-4) |
| 67 | +plt.plot(-x * 1e5, -x * 1e-4) |
65 | 68 | plt.gca().xaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
66 | 69 | plt.gca().yaxis.set_major_formatter(ScalarFormatter(useOffset=False))
|
67 | 70 |
|
68 | 71 | x = np.arange(0, 1, .01)
|
69 | 72 | f = figure(figsize=(6, 6))
|
70 |
| -f.text(0.5, 0.975, 'The new formatter, with mathtext', horizontalalignment='center', |
| 73 | +f.text(0.5, 0.975, 'The new formatter, with mathtext', |
| 74 | + horizontalalignment='center', |
71 | 75 | verticalalignment='top')
|
72 | 76 | plt.subplot(221)
|
73 |
| -plt.plot(x*1e5 + 1e10, x*1e-10 + 1e-5) |
| 77 | +plt.plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5) |
74 | 78 | plt.gca().xaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
75 | 79 | plt.gca().yaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
76 | 80 | plt.subplot(222)
|
77 |
| -plt.plot(x*1e5, x*1e-4) |
| 81 | +plt.plot(x * 1e5, x * 1e-4) |
78 | 82 | plt.gca().xaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
79 | 83 | plt.gca().yaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
80 | 84 | plt.subplot(223)
|
81 |
| -plt.plot(-x*1e5 - 1e10, -x*1e-5 - 1e-10) |
| 85 | +plt.plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10) |
82 | 86 | plt.gca().xaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
83 | 87 | plt.gca().yaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
84 | 88 | plt.subplot(224)
|
85 |
| -plt.plot(-x*1e5, -x*1e-4) |
| 89 | +plt.plot(-x * 1e5, -x * 1e-4) |
86 | 90 | plt.gca().xaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
87 | 91 | plt.gca().yaxis.set_major_formatter(ScalarFormatter(useMathText=True))
|
88 | 92 | plt.show()
|
0 commit comments