赞
踩
matplotlib库
散点图
import matplotlib.pyplot as plt
%matplotlib inline
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
plt.scatter(x, y)
plt.xlabel('x values')
plt.ylabel('y values')
plt.title('X values versus Y values')
plt.xticks([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
plt.show()
条形图
import matplotlib.pyplot as plt
%matplotlib inline
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
plt.bar(x, y)
plt.xlabel('x values')
plt.ylabel('y values')
plt.title('X values versus Y values')
plt.xticks([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
plt.show()
折线图
import matplotlib.pyplot as plt
%matplotlib inline
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
plt.plot(x, y)
plt.xlabel('x values')
plt.ylabel('y values')
plt.title('X values versus Y values')
plt.xticks([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
plt.show()
plt.plot([0, 360], [y, y], color=‘blue’)
plt.plot([0, 0], [0, y], ‘–’, color=‘blue’, )
plt.plot([360, 360], [0, y], ‘–’, color=‘blue’, )
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。