700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > matplotlib 之柱状图/条形图(bar/barh)

matplotlib 之柱状图/条形图(bar/barh)

时间:2024-07-01 13:51:28

相关推荐

matplotlib 之柱状图/条形图(bar/barh)

#导入库import matplotlib.pyplot as pltimport numpy as np#数据np.random.seed(1)#生成随机数种子 使生成hig值不变n = 10x = np.arange(n)hig = np.random.random(n)#绘图(柱状图)plt.bar(x,hig,facecolor = #00FF00,alpha = 0.5)#x,y必不可少for i in range(n):plt.text(x[i],hig[i],\%.2f\%hig[i],ha = center,va = ottom)#显示数字标签hig保留两位小数,水平居中(默认left),va默认bottomplt.bar(x,-hig,facecolor = #0000FF,alpha = 0.5)for i in range(n):plt.text(x[i]

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。