@@ -198,34 +198,21 @@ def histplot(
198198 else get_histogram_axes_title (hists [0 ].axes [0 ])
199199 )
200200
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-
214201 _labels : list [str | None ]
215202 if label is None :
216- _labels = [None ] * len (plottables )
203+ _labels = [None ] * len (hists )
217204 elif isinstance (label , str ):
218- _labels = [label ] * len (plottables )
205+ _labels = [label ] * len (hists )
219206 elif not np .iterable (label ):
220- _labels = [str (label )] * len (plottables )
207+ _labels = [str (label )] * len (hists )
221208 else :
222209 _labels = [str (lab ) for lab in label ]
223210
224211 def iterable_not_string (arg ):
225212 return isinstance (arg , collections .abc .Iterable ) and not isinstance (arg , str )
226213
227214 _chunked_kwargs : list [dict [str , Any ]] = []
228- for _ in range (len (plottables )):
215+ for _ in range (len (hists )):
229216 _chunked_kwargs .append ({})
230217 for kwarg , kwarg_content in kwargs .items ():
231218 # Check if iterable
@@ -249,22 +236,35 @@ def iterable_not_string(arg):
249236 if sort .split ("_" )[0 ] in ["l" , "label" ] and isinstance (_labels , list ):
250237 order = np .argsort (label ) # [::-1]
251238 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]
253240 order = np .argsort (_yields )
254241 if len (sort .split ("_" )) == 2 and sort .split ("_" )[1 ] == "r" :
255242 order = order [::- 1 ]
256243 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."
259246 raise ValueError (msg )
260247 order = np .asarray (sort )
261248 else :
262249 msg = f"Sort type: { sort } not understood."
263250 raise ValueError (msg )
264- plottables = [plottables [ix ] for ix in order ]
251+ hists = [hists [ix ] for ix in order ]
265252 _chunked_kwargs = [_chunked_kwargs [ix ] for ix in order ]
266253 _labels = [_labels [ix ] for ix in order ]
267254
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+
268268 ##########
269269 # Plotting
270270 return_artists : list [StairsArtists | ErrorBarArtists ] = []
@@ -274,7 +274,7 @@ def iterable_not_string(arg):
274274 elif histtype == "barstep" and len (plottables ) == 1 :
275275 histtype = "step"
276276
277- # customize color cycle assignment when stacking to match legend
277+ # # customize color cycle assignment when stacking to match legend
278278 if stack :
279279 plottables = plottables [::- 1 ]
280280 _chunked_kwargs = _chunked_kwargs [::- 1 ]
0 commit comments