具有像堆疊的離散值的直方圖
OrderedDict([(734242, [1, 0, 1]), (734243, [0, 0, 1]), (734244, [0, 0, 0]), (734245, [3, 0, 1]), (734246, [0, 0, 0]), (734247, [0, 0, 0]), (734248, [0, 0, 0]), (734249, [0, 0, 0]), (734250, [0, 0, 0]), (734251, [0, 0, 0]), (734252, [0, 0, 0]), (734253, [0, 0, 0]), (734254, [0, 0, 0]), (734255, [0, 0, 0]), (734256, [0, 0, 0]), (734257, [0, 0, 0]), (734258, [0, 0, 0]), (734259, [1, 0, 0]), (734260, [0, 0, 0]), (734261, [0, 0, 0]), (734262, [0, 0, 0]), (734263, [0, 0, 0]), (734264, [0, 0, 0]), (734265, [0, 0, 0]), (734266, [0, 0, 0]), (734267, [0, 0, 0]), (734268, [0, 0, 0]), (734269, [0, 0, 0]), (734270, [0, 0, 0]), (734271, [0, 0, 0]), (734272, [0, 0, 0]), (734273, [0, 0, 0]), (734274, [0, 0, 0]), (734275, [0, 0, 0]), (734276, [0, 0, 0]), (734277, [0, 0, 0]), (734278, [0, 0, 0]), (734279, [0, 0, 0]), (734280, [0, 0, 0]), (734281, [0, 0, 0]), (734282, [0, 0, 0]), (734283, [0, 0, 0]), (734284, [0, 0, 0]), (734285, [0, 0, 0]), (734286, [0, 0, 0]), (734287, [0, 0, 0]), (734288, [1, 0, 0])])
某些數據(其已經是一個堆疊樣型直方圖),
我將如何創建與此類似
但是x軸上的值取自OrderedDict的關鍵點,並且在該關鍵點處找到的值作爲單個堆疊段的高度?
例如,(734245, [3, 0, 1])
應該使matplotlib在x座標734245處顯示一個高度爲3的條,然後在其頂部顯示一段高度爲0(不可見)的高度爲1的頂點,最後的4號高度。
輸入數據可能變大,大約有10k x的座標,所以性能很重要。
歡迎任何圖書館,matplotlib不是強制性的。
'''類繪圖儀: DEF get_stacked_histo_plot(個體,數據,顏色): globalplot =無 對XPOS,瓦爾斯在data.items(): p_ampl = 0 爲binnum,l_ampl在枚舉(瓦爾斯) (xpos-0.5,p_ampl),(xpos-0.5,l_ampl + p_ampl),(xpos + 0.5,l_ampl + p_ampl),(xpos + 0.5,p_ampl)],rgbcolor = colors [binnum]:[0124] ) p_ampl = l_ampl + p_ampl 如果globalplot: globalplot + = p 其他: globalplot = p 返回globalplot''' – Flavius
(使用sagemath)的作品,但我想知道如果它可能是做得更好 – Flavius