|
12 | 12 | fs = 10 # fontsize
|
13 | 13 |
|
14 | 14 | # demonstrate how to toggle the display of different elements:
|
15 |
| -fig, axes = plt.subplots(nrows=2, ncols=3) |
| 15 | +fig, axes = plt.subplots(nrows=2, ncols=3, figsize=(6,6)) |
16 | 16 | axes[0, 0].boxplot(data, labels=labels)
|
17 | 17 | axes[0, 0].set_title('Default', fontsize=fs)
|
18 | 18 |
|
19 | 19 | axes[0, 1].boxplot(data, labels=labels, showmeans=True)
|
20 | 20 | axes[0, 1].set_title('showmeans=True', fontsize=fs)
|
21 | 21 |
|
22 | 22 | axes[0, 2].boxplot(data, labels=labels, showmeans=True, meanline=True)
|
23 |
| -axes[0, 2].set_title('showmeans=True, meanline=True', fontsize=fs) |
| 23 | +axes[0, 2].set_title('showmeans=True,\nmeanline=True', fontsize=fs) |
24 | 24 |
|
25 | 25 | axes[1, 0].boxplot(data, labels=labels, showbox=False, showcaps=False)
|
26 |
| -axes[1, 0].set_title('Tufte Style (showbox=False, showcaps=False)', fontsize=fs) |
| 26 | +axes[1, 0].set_title('Tufte Style \n(showbox=False,\nshowcaps=False)', fontsize=fs) |
27 | 27 |
|
28 | 28 | axes[1, 1].boxplot(data, labels=labels, notch=True, bootstrap=10000)
|
29 |
| -axes[1, 1].set_title('notch=True, bootstrap=10000', fontsize=fs) |
| 29 | +axes[1, 1].set_title('notch=True,\nbootstrap=10000', fontsize=fs) |
30 | 30 |
|
31 | 31 | axes[1, 2].boxplot(data, labels=labels, showfliers=False)
|
32 | 32 | axes[1, 2].set_title('showfliers=False', fontsize=fs)
|
|
35 | 35 | ax.set_yscale('log')
|
36 | 36 | ax.set_yticklabels([])
|
37 | 37 |
|
| 38 | +fig.subplots_adjust(hspace=0.4) |
38 | 39 | plt.show()
|
39 | 40 |
|
40 | 41 |
|
|
47 | 48 | markerfacecolor='firebrick')
|
48 | 49 | meanlineprops = dict(linestyle='--', linewidth=2.5, color='purple')
|
49 | 50 |
|
50 |
| -fig, axes = plt.subplots(nrows=2, ncols=3) |
| 51 | +fig, axes = plt.subplots(nrows=2, ncols=3, figsize=(6,6)) |
51 | 52 | axes[0, 0].boxplot(data, boxprops=boxprops)
|
52 | 53 | axes[0, 0].set_title('Custom boxprops', fontsize=fs)
|
53 | 54 |
|
54 | 55 | axes[0, 1].boxplot(data, flierprops=flierprops, medianprops=medianprops)
|
55 |
| -axes[0, 1].set_title('Custom medianprops and flierprops', fontsize=fs) |
| 56 | +axes[0, 1].set_title('Custom medianprops\nand flierprops', fontsize=fs) |
56 | 57 |
|
57 | 58 | axes[0, 2].boxplot(data, whis='range')
|
58 | 59 | axes[0, 2].set_title('whis="range"', fontsize=fs)
|
59 | 60 |
|
60 | 61 | axes[1, 0].boxplot(data, meanprops=meanpointprops, meanline=False,
|
61 | 62 | showmeans=True)
|
62 |
| -axes[1, 0].set_title('Custom mean as point', fontsize=fs) |
| 63 | +axes[1, 0].set_title('Custom mean\nas point', fontsize=fs) |
63 | 64 |
|
64 | 65 | axes[1, 1].boxplot(data, meanprops=meanlineprops, meanline=True, showmeans=True)
|
65 |
| -axes[1, 1].set_title('Custom mean as line', fontsize=fs) |
| 66 | +axes[1, 1].set_title('Custom mean\nas line', fontsize=fs) |
66 | 67 |
|
67 | 68 | axes[1, 2].boxplot(data, whis=[15, 85])
|
68 |
| -axes[1, 2].set_title('whis=[15, 85] #percentiles', fontsize=fs) |
| 69 | +axes[1, 2].set_title('whis=[15, 85]\n#percentiles', fontsize=fs) |
69 | 70 |
|
70 | 71 | for ax in axes.flatten():
|
71 | 72 | ax.set_yscale('log')
|
72 | 73 | ax.set_yticklabels([])
|
73 | 74 |
|
74 | 75 | fig.suptitle("I never said they'd be pretty")
|
| 76 | +fig.subplots_adjust(hspace=0.4) |
75 | 77 | plt.show()
|
0 commit comments