3
3
4
4
import numpy as np
5
5
import matplotlib .pyplot as plt
6
+ import matplotlib .ticker as mticker
6
7
from cycler import cycler
7
8
from six .moves import zip
8
9
@@ -146,7 +147,7 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
146
147
arts = {}
147
148
for j , (data , label , sty ) in loop_iter :
148
149
if label is None :
149
- label = 'default set {n}' .format (n = j )
150
+ label = 'dflt set {n}' .format (n = j )
150
151
label = sty .pop ('label' , label )
151
152
vals , edges = hist_func (data )
152
153
if bottoms is None :
@@ -159,7 +160,7 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
159
160
label = label , ** sty )
160
161
bottoms = top
161
162
arts [label ] = ret
162
- ax .legend ()
163
+ ax .legend (fontsize = 10 )
163
164
return arts
164
165
165
166
@@ -178,7 +179,7 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
178
179
stack_data )}
179
180
180
181
# 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 )
182
183
arts = stack_hist (ax1 , stack_data , color_cycle + label_cycle + hatch_cycle ,
183
184
hist_func = hist_func )
184
185
@@ -192,15 +193,15 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
192
193
193
194
# work with labeled data
194
195
195
- fig , (ax1 , ax2 ) = plt .subplots (1 , 2 , figsize = (12 , 6 ),
196
+ fig , (ax1 , ax2 ) = plt .subplots (1 , 2 , figsize = (9 , 4.5 ),
196
197
tight_layout = True , sharey = True )
197
198
198
199
arts = stack_hist (ax1 , dict_data , color_cycle + hatch_cycle ,
199
200
hist_func = hist_func )
200
201
201
202
arts = stack_hist (ax2 , dict_data , color_cycle + hatch_cycle ,
202
203
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