我想修改matplotlib barp中的barposition

2024-04-20 13:58:04 发布

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

我在下面找到了答案 Modifying bar-width and bar-position in matplotlib bar-plot (looping over containers) 但是当我运行代码时,我真的不知道“大小”是什么意思,python告诉我,“大小”是未知的,下面是代码,有人能帮我吗

 for container in axes.containers:
        for i, child in enumerate(container.get_children()):
            child.set_x(df.index[i] - sizes[i]/2)
            plt.setp(child, width=sizes[i])

Tags: and答案代码inchildforplotmatplotlib