如何在python中绘制/绘制图形?

时间:2016-01-03 16:05:20

标签: python-3.x graph charts rating-system

我有一个从0到5的实体的浮点数据,但我想在图表中显示它们,如

price 3.6
___________
look 3.8
_____________
user friendly 4.3
__________________
reliability 2.3
______

所以在python中有任何包或帮助,或建议吗?

1 个答案:

答案 0 :(得分:0)

如果你想要的是用下划线制作的简单条形图,那么可以这样做:

def display(nums,unit = 0.2):
    pairs = zip(("price","look","user friendly", "reliability"),nums)
    for (label,num) in pairs:
        print(label,round(num,1))
        print("_" * round(num/unit))

典型输出:

>>> display((3.6,3.8,4.3,2.3))
price 3.6
__________________
look 3.8
___________________
user friendly 4.3
_____________________
reliability 2.3
___________

如果您想要更复杂的图片,请查看imageComparator