场景
我想画一幅bar图,想要有大标题,x和y的标题,每一个柱图上面标有数字。
记忆
- x,y的数据集
- 画bar图
- title, x和y的label
- show出来
核心
import matplotlib.pyplot as plt
x_data = ['1 node and 1 core', '1 node and 8 cores', '2 nodes and 8 cores']
y_data = [275.92 ,219.332 ,236.87]
plt.bar(x_data, y_data, label="time")
plt.title("Assignment1")
for x,y in enumerate(y_data):
plt.text(x, y, "%s"%y, ha='center', va='bottom')
plt.xlabel("resources")
plt.ylabel("second")
plt.show()
bar图