Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2303939

Browse files
committed
fix pep8 violations in the new boxplot examples
1 parent eab5b52 commit 2303939

File tree

2 files changed

+23
-29
lines changed

2 files changed

+23
-29
lines changed

examples/statistics/boxplot_color_demo.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,34 @@
77
np.random.seed(123)
88
all_data = [np.random.normal(0, std, 100) for std in range(1, 4)]
99

10-
fig, axes = plt.subplots(nrows=1,ncols=2, figsize=(12,5))
10+
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(12, 5))
1111

1212
# rectangular box plot
13-
bplot1 = axes[0].boxplot(all_data,
14-
vert=True, # vertical box aligmnent
15-
patch_artist=True) # fill with color
16-
13+
bplot1 = axes[0].boxplot(all_data,
14+
vert=True, # vertical box aligmnent
15+
patch_artist=True) # fill with color
16+
1717
# notch shape box plot
18-
bplot2 = axes[1].boxplot(all_data,
19-
notch=True, # notch shape
20-
vert=True, # vertical box aligmnent
21-
patch_artist=True) # fill with color
18+
bplot2 = axes[1].boxplot(all_data,
19+
notch=True, # notch shape
20+
vert=True, # vertical box aligmnent
21+
patch_artist=True) # fill with color
2222

2323
# fill with colors
2424
colors = ['pink', 'lightblue', 'lightgreen']
2525
for bplot in (bplot1, bplot2):
2626
for patch, color in zip(bplot['boxes'], colors):
2727
patch.set_facecolor(color)
2828

29-
# adding horizontal grid lines
29+
# adding horizontal grid lines
3030
for ax in axes:
31-
ax.yaxis.grid(True)
31+
ax.yaxis.grid(True)
3232
ax.set_xticks([y+1 for y in range(len(all_data))], )
3333
ax.set_xlabel('xlabel')
3434
ax.set_ylabel('ylabel')
35-
35+
3636
# add x-tick labels
37-
plt.setp(axes, xticks=[y+1 for y in range(len(all_data))],
38-
xticklabels=['x1', 'x2', 'x3', 'x4'],
39-
)
37+
plt.setp(axes, xticks=[y+1 for y in range(len(all_data))],
38+
xticklabels=['x1', 'x2', 'x3', 'x4'])
4039

4140
plt.show()
42-
43-

examples/statistics/boxplot_vs_violin_demo.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,29 @@
1111
import matplotlib.pyplot as plt
1212
import numpy as np
1313

14-
fig, axes = plt.subplots(nrows=1,ncols=2, figsize=(12,5))
14+
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(12, 5))
1515

1616
# generate some random test data
1717
all_data = [np.random.normal(0, std, 100) for std in range(6, 10)]
1818

1919
# plot violin plot
2020
axes[0].violinplot(all_data,
21-
showmeans=False,
22-
showmedians=True
23-
)
21+
showmeans=False,
22+
showmedians=True)
2423
axes[0].set_title('violin plot')
2524

2625
# plot box plot
2726
axes[1].boxplot(all_data)
2827
axes[1].set_title('box plot')
2928

30-
# adding horizontal grid lines
29+
# adding horizontal grid lines
3130
for ax in axes:
32-
ax.yaxis.grid(True)
33-
ax.set_xticks([y+1 for y in range(len(all_data))], )
31+
ax.yaxis.grid(True)
32+
ax.set_xticks([y+1 for y in range(len(all_data))])
3433
ax.set_xlabel('xlabel')
3534
ax.set_ylabel('ylabel')
3635

3736
# add x-tick labels
38-
plt.setp(axes, xticks=[y+1 for y in range(len(all_data))],
39-
xticklabels=['x1', 'x2', 'x3', 'x4'],
40-
)
41-
42-
plt.show()
37+
plt.setp(axes, xticks=[y+1 for y in range(len(all_data))],
38+
xticklabels=['x1', 'x2', 'x3', 'x4'])
39+
plt.show()

0 commit comments

Comments
 (0)