@@ -198,34 +198,21 @@ def histplot(
198
198
else get_histogram_axes_title (hists [0 ].axes [0 ])
199
199
)
200
200
201
- plottables , flow_info = get_plottables (
202
- hists ,
203
- bins = final_bins ,
204
- w2 = w2 ,
205
- w2method = w2method ,
206
- yerr = yerr ,
207
- stack = stack ,
208
- density = density ,
209
- binwnorm = binwnorm ,
210
- flow = flow ,
211
- )
212
- flow_bins , underflow , overflow = flow_info
213
-
214
201
_labels : list [str | None ]
215
202
if label is None :
216
- _labels = [None ] * len (plottables )
203
+ _labels = [None ] * len (hists )
217
204
elif isinstance (label , str ):
218
- _labels = [label ] * len (plottables )
205
+ _labels = [label ] * len (hists )
219
206
elif not np .iterable (label ):
220
- _labels = [str (label )] * len (plottables )
207
+ _labels = [str (label )] * len (hists )
221
208
else :
222
209
_labels = [str (lab ) for lab in label ]
223
210
224
211
def iterable_not_string (arg ):
225
212
return isinstance (arg , collections .abc .Iterable ) and not isinstance (arg , str )
226
213
227
214
_chunked_kwargs : list [dict [str , Any ]] = []
228
- for _ in range (len (plottables )):
215
+ for _ in range (len (hists )):
229
216
_chunked_kwargs .append ({})
230
217
for kwarg , kwarg_content in kwargs .items ():
231
218
# Check if iterable
@@ -249,22 +236,35 @@ def iterable_not_string(arg):
249
236
if sort .split ("_" )[0 ] in ["l" , "label" ] and isinstance (_labels , list ):
250
237
order = np .argsort (label ) # [::-1]
251
238
elif sort .split ("_" )[0 ] in ["y" , "yield" ]:
252
- _yields = [np .sum (_h .values ) for _h in plottables ] # type: ignore[var-annotated]
239
+ _yields = [np .sum (_h .values ()) for _h in hists ] # type: ignore[var-annotated]
253
240
order = np .argsort (_yields )
254
241
if len (sort .split ("_" )) == 2 and sort .split ("_" )[1 ] == "r" :
255
242
order = order [::- 1 ]
256
243
elif isinstance (sort , (list , np .ndarray )):
257
- if len (sort ) != len (plottables ):
258
- msg = f"Sort indexing array is of the wrong size - { len (sort )} , { len (plottables )} expected."
244
+ if len (sort ) != len (hists ):
245
+ msg = f"Sort indexing array is of the wrong size - { len (sort )} , { len (hists )} expected."
259
246
raise ValueError (msg )
260
247
order = np .asarray (sort )
261
248
else :
262
249
msg = f"Sort type: { sort } not understood."
263
250
raise ValueError (msg )
264
- plottables = [plottables [ix ] for ix in order ]
251
+ hists = [hists [ix ] for ix in order ]
265
252
_chunked_kwargs = [_chunked_kwargs [ix ] for ix in order ]
266
253
_labels = [_labels [ix ] for ix in order ]
267
254
255
+ plottables , flow_info = get_plottables (
256
+ hists ,
257
+ bins = final_bins ,
258
+ w2 = w2 ,
259
+ w2method = w2method ,
260
+ yerr = yerr ,
261
+ stack = stack ,
262
+ density = density ,
263
+ binwnorm = binwnorm ,
264
+ flow = flow ,
265
+ )
266
+ flow_bins , underflow , overflow = flow_info
267
+
268
268
##########
269
269
# Plotting
270
270
return_artists : list [StairsArtists | ErrorBarArtists ] = []
@@ -274,7 +274,7 @@ def iterable_not_string(arg):
274
274
elif histtype == "barstep" and len (plottables ) == 1 :
275
275
histtype = "step"
276
276
277
- # customize color cycle assignment when stacking to match legend
277
+ # # customize color cycle assignment when stacking to match legend
278
278
if stack :
279
279
plottables = plottables [::- 1 ]
280
280
_chunked_kwargs = _chunked_kwargs [::- 1 ]
0 commit comments