Skip to content

Commit

Permalink
fix pep8 violations in the new boxplot examples
Browse files Browse the repository at this point in the history
  • Loading branch information
twmr committed Nov 15, 2014
1 parent eab5b52 commit 2303939
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
31 changes: 14 additions & 17 deletions examples/statistics/boxplot_color_demo.py
Expand Up @@ -7,37 +7,34 @@
np.random.seed(123)
all_data = [np.random.normal(0, std, 100) for std in range(1, 4)]

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

# rectangular box plot
bplot1 = axes[0].boxplot(all_data,
vert=True, # vertical box aligmnent
patch_artist=True) # fill with color
bplot1 = axes[0].boxplot(all_data,
vert=True, # vertical box aligmnent
patch_artist=True) # fill with color

# notch shape box plot
bplot2 = axes[1].boxplot(all_data,
notch=True, # notch shape
vert=True, # vertical box aligmnent
patch_artist=True) # fill with color
bplot2 = axes[1].boxplot(all_data,
notch=True, # notch shape
vert=True, # vertical box aligmnent
patch_artist=True) # fill with color

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

# adding horizontal grid lines
# adding horizontal grid lines
for ax in axes:
ax.yaxis.grid(True)
ax.yaxis.grid(True)
ax.set_xticks([y+1 for y in range(len(all_data))], )
ax.set_xlabel('xlabel')
ax.set_ylabel('ylabel')

# add x-tick labels
plt.setp(axes, xticks=[y+1 for y in range(len(all_data))],
xticklabels=['x1', 'x2', 'x3', 'x4'],
)
plt.setp(axes, xticks=[y+1 for y in range(len(all_data))],
xticklabels=['x1', 'x2', 'x3', 'x4'])

plt.show()


21 changes: 9 additions & 12 deletions examples/statistics/boxplot_vs_violin_demo.py
Expand Up @@ -11,32 +11,29 @@
import matplotlib.pyplot as plt
import numpy as np

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

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

# plot violin plot
axes[0].violinplot(all_data,
showmeans=False,
showmedians=True
)
showmeans=False,
showmedians=True)
axes[0].set_title('violin plot')

# plot box plot
axes[1].boxplot(all_data)
axes[1].set_title('box plot')

# adding horizontal grid lines
# adding horizontal grid lines
for ax in axes:
ax.yaxis.grid(True)
ax.set_xticks([y+1 for y in range(len(all_data))], )
ax.yaxis.grid(True)
ax.set_xticks([y+1 for y in range(len(all_data))])
ax.set_xlabel('xlabel')
ax.set_ylabel('ylabel')

# add x-tick labels
plt.setp(axes, xticks=[y+1 for y in range(len(all_data))],
xticklabels=['x1', 'x2', 'x3', 'x4'],
)

plt.show()
plt.setp(axes, xticks=[y+1 for y in range(len(all_data))],
xticklabels=['x1', 'x2', 'x3', 'x4'])
plt.show()

0 comments on commit 2303939

Please sign in to comment.