|
1 | | -import matplotlib.pyplot as plt |
2 | | -import numpy as np |
3 | | -from matplotlib.ticker import OldScalarFormatter, ScalarFormatter |
| 1 | +""" |
| 2 | +========================================= |
| 3 | +Tick formatting using the ScalarFromatter |
| 4 | +========================================= |
4 | 5 |
|
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()) |
| 6 | +The example shows use of ScalarFormatter with different settings. |
17 | 7 |
|
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()) |
| 8 | +Example 1 : Default |
21 | 9 |
|
22 | | -ax4.plot(-x * 1e5, -x * 1e-4) |
23 | | -ax4.xaxis.set_major_formatter(OldScalarFormatter()) |
24 | | -ax4.yaxis.set_major_formatter(OldScalarFormatter()) |
| 10 | +Example 2 : With no Numerical Offset |
25 | 11 |
|
26 | | -fig.subplots_adjust(wspace=0.7, hspace=0.6) |
| 12 | +Example 3 : With Mathtext |
| 13 | +""" |
| 14 | +import matplotlib.pyplot as plt |
| 15 | +import numpy as np |
| 16 | +from matplotlib.ticker import ScalarFormatter |
27 | 17 |
|
28 | | -# Example 2 |
| 18 | +# Example 1 |
29 | 19 | x = np.arange(0, 1, .01) |
30 | 20 | fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2, figsize=(6, 6)) |
31 | 21 | fig.text(0.5, 0.975, 'The new formatter, default settings', |
|
50 | 40 |
|
51 | 41 | fig.subplots_adjust(wspace=0.7, hspace=0.6) |
52 | 42 |
|
53 | | -# Example 3 |
| 43 | +# Example 2 |
54 | 44 | x = np.arange(0, 1, .01) |
55 | 45 | fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2, figsize=(6, 6)) |
56 | 46 | fig.text(0.5, 0.975, 'The new formatter, no numerical offset', |
|
75 | 65 |
|
76 | 66 | fig.subplots_adjust(wspace=0.7, hspace=0.6) |
77 | 67 |
|
78 | | -# Example 4 |
| 68 | +# Example 3 |
79 | 69 | x = np.arange(0, 1, .01) |
80 | 70 | fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2, figsize=(6, 6)) |
81 | 71 | fig.text(0.5, 0.975, 'The new formatter, with mathtext', |
|
0 commit comments