8000 DOC: impoved example boxplot figure layout and confirmed that they bu… · matplotlib/matplotlib@676f28e · GitHub
[go: up one dir, main page]

Skip to content

Commit 676f28e

Browse files
committed
DOC: impoved example boxplot figure layout and confirmed that they build with docs
1 parent 9b97ac4 commit 676f28e

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

examples/statistics/boxplot_demo.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212
fs = 10 # fontsize
1313

1414
# 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))
1616
axes[0, 0].boxplot(data, labels=labels)
1717
axes[0, 0].set_title('Default', fontsize=fs)
1818

1919
axes[0, 1].boxplot(data, labels=labels, showmeans=True)
2020
axes[0, 1].set_title('showmeans=True', fontsize=fs)
2121

2222
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)
2424

2525
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)
2727

2828
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)
3030

3131
axes[1, 2].boxplot(data, labels=labels, showfliers=False)
3232
axes[1, 2].set_title('showfliers=False', fontsize=fs)
@@ -35,6 +35,7 @@
3535
ax.set_yscale('log')
3636
ax.set_yticklabels([])
3737

38+
fig.subplots_adjust(hspace=0.4)
3839
plt.show()
3940

4041

@@ -47,29 +48,30 @@
4748
markerfacecolor='firebrick')
4849
meanlineprops = dict(linestyle='--', linewidth=2.5, color='purple')
4950

50-
fig, axes = plt.subplots(nrows=2, ncols=3)
51+
fig, axes = plt.subplots(nrows=2, ncols=3, figsize=(6,6))
5152
axes[0, 0].boxplot(data, boxprops=boxprops)
5253
axes[0, 0].set_title('Custom boxprops', fontsize=fs)
5354

5455
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)
5657

5758
axes[0, 2].boxplot(data, whis='range')
5859
axes[0, 2].set_title('whis="range"', fontsize=fs)
5960

6061
axes[1, 0].boxplot(data, meanprops=meanpointprops, meanline=False,
6162
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)
6364

6465
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)
6667

6768
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)
6970

7071
for ax in axes.flatten():
7172
ax.set_yscale('log')
7273
ax.set_yticklabels([])
7374

7475
fig.suptitle("I never said they'd be pretty")
76+
fig.subplots_adjust(hspace=0.4)
7577
plt.show()

examples/statistics/bxp_demo.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@
2424
fs = 10 # fontsize
2525

2626
# demonstrate how to toggle the display of different elements:
27-
fig, axes = plt.subplots(nrows=2, ncols=3)
27+
fig, axes = plt.subplots(nrows=2, ncols=3, figsize=(6,6))
2828
axes[0, 0].bxp(stats)
2929
axes[0, 0].set_title('Default', fontsize=fs)
3030

3131
axes[0, 1].bxp(stats, showmeans=True)
3232
axes[0, 1].set_title('showmeans=True', fontsize=fs)
3333

3434
axes[0, 2].bxp(stats, showmeans=True, meanline=True)
35-
axes[0, 2].set_title('showmeans=True, meanline=True', fontsize=fs)
35+
axes[0, 2].set_title('showmeans=True,\nmeanline=True', fontsize=fs)
3636

3737
axes[1, 0].bxp(stats, showbox=False, showcaps=False)
38-
axes[1, 0].set_title('Tufte Style (showbox=False, showcaps=False)', fontsize=fs)
38+
axes[1, 0].set_title('Tufte Style\n(showbox=False,\nshowcaps=False)', fontsize=fs)
3939

4040
axes[1, 1].bxp(stats, shownotches=True)
4141
axes[1, 1].set_title('notch=True', fontsize=fs)
@@ -47,6 +47,7 @@
4747
ax.set_yscale('log')
4848
ax.set_yticklabels([])
4949

50+
fig.subplots_adjust(hspace=0.4)
5051
plt.show()
5152

5253

@@ -59,23 +60,24 @@
5960
markerfacecolor='firebrick')
6061
meanlineprops = dict(linestyle='--', linewidth=2.5, color='purple')
6162

62-
fig, axes = plt.subplots(nrows=2, ncols=2)
63+
fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(6,6))
6364
axes[0, 0].bxp(stats, boxprops=boxprops)
6465
axes[0, 0].set_title('Custom boxprops', fontsize=fs)
6566

6667
axes[0, 1].bxp(stats, flierprops=flierprops, medianprops=medianprops)
67-
axes[0, 1].set_title('Custom medianprops and flierprops', fontsize=fs)
68+
axes[0, 1].set_title('Custom medianprops\nand flierprops', fontsize=fs)
6869

6970
axes[1, 0].bxp(stats, meanprops=meanpointprops, meanline=False,
7071
showmeans=True)
71-
axes[1, 0].set_title('Custom mean as point', fontsize=fs)
72+
axes[1, 0].set_title('Custom mean\nas point', fontsize=fs)
7273

7374
axes[1, 1].bxp(stats, meanprops=meanlineprops, meanline=True, showmeans=True)
74-
axes[1, 1].set_title('Custom mean as line', fontsize=fs)
75+
axes[1, 1].set_title('Custom mean\nas line', fontsize=fs)
7576

7677
for ax in axes.flatten():
7778
ax.set_yscale('log')
7879
ax.set_yticklabels([])
7980

8081
fig.suptitle("I never said they'd be pretty")
82+
fig.subplots_adjust(hspace=0.4)
8183
plt.show()

0 commit comments

Comments
 (0)
0