Вот решение, использующее ImmutableJS, где items
- это неизменяемый список, а size
- необходимый размер группировки.
const partition = ((items, size) => {
return items.groupBy((items, i) => Math.floor(i/size))
})
До сих пор я не думал о гистограммах с нижним смещением, что выглядит неплохо:
layer0 = np.random.random(10)
fig, ax = plt.subplots(1,1, figsize=(15/1.3,1.5*2.5),)# sharey=True)
ind = np.arange(10, dtype=np.float64)*1#cordx
height=0.03
width=0.8
ax.bar(ind[0::2]-width/2, height, width=width, bottom=layer0[0::2]-height)
ax.bar(ind[0::2]+width/2, height, width=width, bottom=layer0[1::2]-height)
ax.set_ylim(-0.,1.05)
plt.grid(color='black', which='major', axis='x', linestyle='-', lw=0.8)