使用熊猫对齐堆积的条形图

时间:2018-08-22 20:03:42

标签: python pandas dataframe stacked

xantho99 = [545/60, 6/60, 1688/60, 44/60]
buch99 = [51/60, 2/60, 576/60, 7/60]
myco99 = [519/60, 9/60, 889/60, 28/60]
cory99 = [247/60, 5/60, 1160/60, 28/60]
xantho90 = [545/60, 8/60, 989/60, 27/60]
buch90 = [51/60, 3/60, 523/60, 5/60]
myco90 = [519/60, 11/60, 802/60, 32/60]
cory90 = [247/60, 7/60, 899/60, 27/60]
xanthouc = [545/60, 0/60, 5407/60, 193/60]
buchuc = [51/60, 0/60, 1014/60, 20/60]
mycouc = [519/60, 0/60, 4644/60, 101/60]
coryuc = [247/60, 0/60, 2384/60, 77/60]
df = pd.DataFrame([xantho, xantho99, xantho90, buch, buch99, buch90, myco, 
myco99, myco90, cory, cory99, cory90], columns=['Prodigal', 'Cd-hit', 
'PSOT', 'Zusammenführen'], index=["X", "X","X", "B", "B","B", "M", "M","M", 
"C", "C","C"])
df.columns.name = "Abschnitt"
current_palette = "blue", "green", "red", "yellow"
ax = df.plot.bar(stacked=True, title="Zeitbedarf der einzelnen Abschnitte 
(Xanthomonas)", xlim=(0, sum(xantho)*1.1), color=current_palette, rot=0 [enter image description here][1]ax.set_xlabel("Zeit in Stunden")

嘿,我需要将所有堆叠的条形图与相同的x索引对齐。 这样它们之间就没有空间了,您可以看到4个独立的部分作为索引,每个部分都有3个图表。 谢谢!

0 个答案:

没有答案