gpt4 book ai didi

python - 如何用matplotlib绘制水平百分比条形图?

转载 作者:行者123 更新时间:2023-12-05 08:52:56 24 4
gpt4 key购买 nike

是否可以使用我在下面附加的 matplotlib 绘制类似的图形?

enter image description here

最佳答案

使用 barh方法,类似于:

import matplotlib.pyplot as plt

never = [74]
seldom = [18]
undecided = [8]

y = [0]

plt.barh(y, never, color='#b5ffb9', edgecolor='white')
plt.barh(y, seldom, left=never, color='#f9bc86', edgecolor='white')
plt.barh(y, undecided, left=[100-i for i in undecided], color='#a3acff', edgecolor='white')

plt.show()

输出:

enter image description here

关于python - 如何用matplotlib绘制水平百分比条形图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55119952/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com