|
11 | 11 | from basic_units import cm, inch
|
12 | 12 | import matplotlib.pyplot as plt
|
13 | 13 |
|
14 |
| - |
15 | 14 | cms = cm * np.arange(0, 10, 2)
|
16 |
| -bottom = 0*cm |
17 |
| -width = 0.8*cm |
| 15 | +bottom = 0 * cm |
| 16 | +width = 0.8 * cm |
18 | 17 |
|
19 |
| -fig = plt.figure() |
| 18 | +fig, axs = plt.subplots(2, 2) |
20 | 19 |
|
21 |
| -ax1 = fig.add_subplot(2, 2, 1) |
22 |
| -ax1.bar(cms, cms, bottom=bottom) |
| 20 | +axs[0, 0].bar(cms, cms, bottom=bottom) |
23 | 21 |
|
24 |
| -ax2 = fig.add_subplot(2, 2, 2) |
25 |
| -ax2.bar(cms, cms, bottom=bottom, width=width, xunits=cm, yunits=inch) |
| 22 | +axs[0, 1].bar(cms, cms, bottom=bottom, width=width, xunits=cm, yunits=inch) |
26 | 23 |
|
27 |
| -ax3 = fig.add_subplot(2, 2, 3) |
28 |
| -ax3.bar(cms, cms, bottom=bottom, width=width, xunits=inch, yunits=cm) |
29 |
| -ax3.set_xlim(2, 6) # scalars are interpreted in current units |
| 24 | +axs[1, 0].bar(cms, cms, bottom=bottom, width=width, xunits=inch, yunits=cm) |
| 25 | +axs[1, 0].set_xlim(2, 6) # scalars are interpreted in current units |
30 | 26 |
|
31 |
| -ax4 = fig.add_subplot(2, 2, 4) |
32 |
| -ax4.bar(cms, cms, bottom=bottom, width=width, xunits=inch, yunits=inch) |
33 |
| -#fig.savefig('simple_conversion_plot.png') |
34 |
| -ax4.set_xlim(2*cm, 6*cm) # cm are converted to inches |
| 27 | +axs[1, 1].bar(cms, cms, bottom=bottom, width=width, xunits=inch, yunits=inch) |
| 28 | +axs[1, 1].set_xlim(2 * cm, 6 * cm) # cm are converted to inches |
35 | 29 |
|
| 30 | +fig.tight_layout() |
36 | 31 | plt.show()
|
0 commit comments