My histogram is having a Regular
and a strCategory
axis and I want to show the cumulative sum of the categories, but with the different components stacked on top of each other.
I found out I can just use np.cumsum(axis=<category axis>)
to calculate the cumulative sum and create a new histogram from that. In had also managed to draw a stacked histogram by plotting multiple plt.bar
with different bottom=...
arguments taken from the cumulative sums. But I dislike that visualy, because I want to have a black outline for my components, but no outlines for the individual bins, as seen in the screenshot.
Hi, I used to be able to modify histogram contents like this
import boost_histogram as bh
import numpy as np
bins = [0, 1, 2]
hist = bh.Histogram(bh.axis.Variable(bins), storage=bh.storage.Weight())
yields = [3, 4]
var = [0.1, 0.2]
hist[...] = np.stack([yields, var], axis=-1)
hist.view().value /= 2
That worked until boost-histogram
version 0.11.1
. In the current master it does not anymore, I think scikit-hep/boost-histogram#475 changes the behavior:
Traceback (most recent call last):
File "test.py", line 10, in <module>
hist.view().value /= 2
File "[...]/boost_histogram/_internal/view.py", line 57, in fset
self[name] = value
File "[...]/boost_histogram/_internal/view.py", line 49, in __setitem__
raise ValueError("Needs matching ndarray or n+1 dim array")
ValueError: Needs matching ndarray or n+1 dim array
Is there another way to achieve this now?
hist.view() /= 2
.
python-3.8
package, you still get pip 9 even on Python 3.8!!! (which is totally unsupported). I hate distro packaging sometimes…