I have a stacked histogram made using matplotlib. It has of course multiple bins (on per sector) and each bin/bar is further segmented in subsectors (stacked histogram).
I'm wondering how I could get the datapoints, do some math (let's say divide each bin by it's total value), and than set the new datapoints.
How I expect it to work:
import matplotlib.plt as plt
ax = plt.subplt(111)
h = ax.hist((subsector1,subsector2,subsector3), bins = 20, stacked=True)
y_data = h.get_yData
The shape of y_data would be something like 20 x 3 (bins x subsectors)
new_y_data = y_data normalized by total on each bin
The shape of new_y_data would also be like 20 x 3, but the sum on each bin would be 1 (or 100%)
new_h = h.set_yData(new_y_data)
new_h would look more like a bar plot, with equal sized bars, but different subsector distributions on each bar..
Is this even possible in python matplotlib?