If I understand your question correctly, I think the code below will do what you offer. This is slightly different from the approach you were considering, and I'm not sure if it is more effective. Despite this, it usually helps to see how someone else will do something. It assumes an already created pdf (histogram) with bins represented by varialble "bins" and the bin width represented by the "binwidth" variable.
gray = (.5,.5,.5)
orange = (1.0, 0.647, 0.0)
red = (1.0, 0.0, 0.0)
clrs = [gray for xx in bins]
idxs = pdf.argsort()
idxs = idxs[::-1]
oranges = idxs[(cumsum(pdf[idxs])*binwidth < 0.8).nonzero()]
reds = idxs[(cumsum(pdf[idxs])*binwidth < 0.6).nonzero()]
for idx in oranges:
clrs[idx] = orange
for idx in reds:
clrs[idx] = red
bar(left=bins,height=pdf,width=binwidth,color=clrs)

source
share