scikit-hep/histbook

marker() should place marker at bin center

Closed this issue · 2 comments

I'm trying to generate a standard HEP plot: stacks of simulated estimates overlaid with data points.

import histbook

array = numpy.random.normal(0, 1, 100)
histogram1 = Hist(bin("data", 10, -5, 5))
histogram1.fill(data=array)

array = numpy.random.normal(1, 1, 100)
histogram2 = Hist(bin("data", 10, -5, 5))
histogram2.fill(data=array)

array = numpy.random.normal(0, 1, 100)
data_hist = Hist(bin("data", 10, -5, 5))
data_hist.fill(data=array)

group = Hist.group(by='sample', h1 = histogram1, h2 = histogram2)
group.stack("sample").area("data").to(canvas)
overlay(group.stack("sample").area("data"), data_hist.marker()).to(canvas)

the results I get, looks like it's doing the right thing, but the markers for the data histogram are on the bin edge. I think it would be more intuitive if they were in the bin center (also if there were some more styling option, I'd plot is as black filled circular markers)

screenshot

Something's broken because there's explicit code to make the points go in the center, not the edges. I'll take a look.

For the plot style, I'm letting Vega-Lite choose things, rather than try to strong-arm it. The marker method has a markerstyle option that passes directly into the Vega-Lite JSON. I haven't played with it to find out if it gives the user enough freedom or if another handle will be necessary.

As it turns out, I didn't really have code to handle that case. I was handling a similar case and misremembered. It's fixed now.