|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import numpy as np
import matplotlib.pyplot as plt
N=5
y=【20,10,30,25,15】
index=np.arange(N)
# pl=plt.bar(left=0,bottom=index,width=y,color='red',height=0.5,orietation='horizontal')
pl=plt.barh(left=0,bottom=index,width=y)
plt.show()
怪了,我的执行不出来TypeError: barh() missing 1 required positional argument: 'y' 用pycharm
bottom改成y即可,这里的y不是你定义的列表y,而是barh的关键字参数y
- import numpy as np
- import matplotlib.pyplot as plt
- N=5
- y=[20,10,30,25,15]
- index=np.arange(N)
- # pl=plt.bar(left=0,bottom=index,width=y,color='red',height=0.5,orietation='horizontal')
- pl=plt.barh(left=0,y=index,width=y)
- plt.show()
复制代码
|
|