用matplotlib绘制简单的折线

如图:

import matplotlib.pyplot as plt
//引入matplotlib.pylot,用plt来替代
input_value = [1,2,3,4,5]
//设置横坐标数值
squares = [1,4,9,16,25]
//设置纵坐标数值
plt.plot(input_value,squares,linewidth=5)
//绘制图像(输入址,输出值,线宽)
plt.title("Square Number",fontsize=24)
//设置图像title
plt.xlabel("Value",fontsize=14)
//设置横坐标的名称,文字大小
plt.ylabel("Square of Value",fontsize=14)
//同上
plt.show()
//显示图片

猜你喜欢

转载自www.cnblogs.com/aprogrammerwithoutemotion/p/9079473.html