ipython notebook 使用 matplotlib画图

matplotlib 绘制折线图

from matplotlib import pyplot as plt
%pylab inline#jupyter 要加这句


x = [1,2,3,4,5]
y = [num**2 for num in x]
plt.plot(x, y, color='green', marker='o', linestyle='solid')
plt.title('x**2')
plt.xlabel('x value')
plt.ylabel('y value')
plt.show()
# plt.savefig('plot')

matplot绘制条形图

name = ['Amy', 'Sam', 'Bob', 'Tom']
salary = [100, 200, 30, 491]

plt.xlabel('names')
plt.ylabel('salary')
plt.title('all money money go my home')

plt.bar(name, salary)
plt.savefig("money.png")

猜你喜欢

转载自blog.csdn.net/weixin_38781498/article/details/80339114