gpt4 book ai didi

python - Pandas,matplotlib,想在图表上添加一些注释,例如 "mean"、 "variance"等

转载 作者:行者123 更新时间:2023-12-01 08:41:03 26 4
gpt4 key购买 nike

我对 Python 2.7 和 Pandas 相当陌生。我有一个条形图,想添加注释,如 mean , variance等等。我已经在上面的图中计算过了。我当前的图表如下所示:

enter image description here

连同这行代码:

matplotlib.pyplot.title('All the observation', fontsize=16)
matplotlib.pyplot.annotate( mean, ( 0 , 0), ( 0, 14000), fontsize=16)
matplotlib.pyplot.show()

有人知道如何以正确且良好的方式在图表上添加平均值等吗?

预先感谢您的帮助!

最好,维克托

最佳答案

你可以使用这个:

matplotlib.pyplot.figtext(.6, .8, "Mean = {}".format(mean))

如果您有更多值要添加:

plt.figtext(.6, .8, "Mean = {}\nVariance = {}".format(mean, variance))

enter image description here

诗。通常 matplotlib.pyplot 是这样导入的:

import matplotlib.pyplot as plt

关于python - Pandas,matplotlib,想在图表上添加一些注释,例如 "mean"、 "variance"等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53496120/

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