目录
一、安装matplotlib
在PyCharm中安装很简单,File--Settings--Project--Python Interpreter
二、绘制简单的折线
import matplotlib.pyplot as plt
squares=[1,4,9,16,25,49]
plt.plot(squares)
plt.show()
1、修改标签和文字
import matplotlib.pyplot as plt
squares=[1,4,9,16,25,49]
plt.plot(squares,linewidth=7)
'''设置标题,坐标轴'''
plt.title('Square Numbers',fontsize=24)
plt.xlabel('Value',fontsize=24)
plt.ylabel('Square of Value',fontsize=14)
'''刻度标记'''
plt.tick_params(axis='both',labelsize=14)
plt.show()
2、校正图形
import matplotlib.pyplot as plt
values=[1,2,3,4,5,7]
squares=[1,4,9,16,25,49]
plt.plot(values,squares,linewidth=7)
'''设置标题,坐标轴'''