在matplotlib中,刻度不与堆叠条形图一起显示

2024-05-15 06:13:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我在matplotlib中有一个堆叠条形图,除了在绘图中看不到XTick之外,该条形图很好

fig, axes = plt.subplots(6, 1, sharex=True, figsize=(20, 10), subplot_kw=dict(frameon=True))

n = 6

i=0
for lineage, j in zip(['a', 'b', 'c', 'd', 'e', 'f'], axes.flatten()):
    x=list(map(lambda x: int(x.strip()[1:-1]), lineage_snp[lineage].value_counts().index))
    y=list(lineage_snp[lineage].value_counts().values/lin_counts[lineage])
    j.bar(x, y, label = lineage, alpha=1, width=100, color = colors[lineage])
    j.legend(loc = 'upper left')
    j.grid(True)
    plt.subplots_adjust(hspace=.0)
    i+=1
   
plt.xticks(rotation=0)
plt.show()

我错过了什么?如果我保持网格打开,我可以得到勾号所在的网格,但我更希望网格关闭,并且标签上只显示一个勾号


Tags: true网格绘图matplotlibvaluepltlistlineage

热门问题