Skip to content

Commit 816fa1f

Browse files
committed
DOC: tweaked example
1 parent 3c077a8 commit 816fa1f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

examples/api/filled_step.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import numpy as np
55
import matplotlib.pyplot as plt
6+
import matplotlib.ticker as mticker
67
from cycler import cycler
78
from six.moves import zip
89

@@ -146,7 +147,7 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
146147
arts = {}
147148
for j, (data, label, sty) in loop_iter:
148149
if label is None:
149-
label = 'default set {n}'.format(n=j)
150+
label = 'dflt set {n}'.format(n=j)
150151
label = sty.pop('label', label)
151152
vals, edges = hist_func(data)
152153
if bottoms is None:
@@ -159,7 +160,7 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
159160
label=label, **sty)
160161
bottoms = top
161162
arts[label] = ret
162-
ax.legend()
163+
ax.legend(fontsize=10)
163164
return arts
164165

165166

@@ -178,7 +179,7 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
178179
stack_data)}
179180

180181
# work with plain arrays
181-
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 6), tight_layout=True)
182+
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9, 4.5), tight_layout=True)
182183
arts = stack_hist(ax1, stack_data, color_cycle + label_cycle + hatch_cycle,
183184
hist_func=hist_func)
184185

@@ -192,15 +193,15 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
192193

193194
# work with labeled data
194195

195-
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 6),
196+
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9, 4.5),
196197
tight_layout=True, sharey=True)
197198

198199
arts = stack_hist(ax1, dict_data, color_cycle + hatch_cycle,
199200
hist_func=hist_func)
200201

201202
arts = stack_hist(ax2, dict_data, color_cycle + hatch_cycle,
202203
hist_func=hist_func, labels=['set 0', 'set 3'])
203-
204-
ax1.set_ylabel('counts')
205-
ax1.set_xlabel('x')
206-
ax2.set_xlabel('x')
204+
ax1.xaxis.set_major_locator(mticker.MaxNLocator(5))
205+
ax1.set_xlabel('counts')
206+
ax1.set_ylabel('x')
207+
ax2.set_ylabel('x')

0 commit comments

Comments
 (0)