【记录】python matplotlib 画显示数据的柱状图

from matplotlib import pyplot as plt
import numpy as np

def f(x):
    return -1.0 * x + np.log(np.exp(x)+3)

x = range(-10,10)
y = [f(_x) for _x in x]
y_label = ["{:.2f}".format(_y) for _y in y]
plt.bar(x, y)
for a, b, label in zip(x, y, y_label):
    plt.text(a, b, label, ha='center', va='bottom')
plt.show()
myplot.png

你可能感兴趣的:(【记录】python matplotlib 画显示数据的柱状图)