matplotlib- 数据可视化
1. 安装
step1:安装matplotlib
pip install matplotlib
Note: you may need to restart the kernel to use updated packages.
step2:更新(有待确定)
conda upgrade notebook
conda upgrade jupyter
`
step3:测试
import matplotlib
若无错误提示,即认为安装正确
2. 图标的制作
- 2.1折线图
import matplotlib.pyplot as plt #导入pyplot模块
square = [ 1, 4, 9, 16, 25 ] #平方函数
plt.plot (square) #plot()画图
plt.show() #plt.show()图片查看
- 修改标签和线条加粗
plt.plot(squares, linewidth = 5) #改变线条粗读
plt.title('square numbers' , fontsize = 24) #设置标题
plt. xlabel('value', fontsize = 14) #设置x轴
plt.ylabel('square of value' , fontsize = 14) #设置y轴
plt.tick_params(axis = 'both', labelsize =14) #设置刻度大小