python 在数据科学中的应用之matplotlib

2023-06-25,,

1、matplotlib模块生成直线图和散点图

>>>import  matplotlib.pyplot as plt
>>>year = [1950,1970,1990,2010]#作为x轴
>>>pop = [2.519,3.692,5.263,6.972]]#作为Y轴
>>>plt.plot(year,pop)#直线图
[<matplotlib.lines.Line2D object at 0x000001A6BA9874E0>]
>>>plt.show()#显示直线图
>>>plt.scatter(year,pop)#散点图
<matplotlib.collections.PathCollection object at 0x000001A6BA941BE0>
>>>plt.show()#显示散点图

2、、matplotlib模块生成直方图

>>>import  matplotlib.pyplot as plt
>>> values = [0,0.6,1.4,1.6,2.2,2.5,2.6,3.2,3.5,3.9,4.2,6]
>>> plt.hist(values,bins=3)
(array([ 4., 6., 2.]), array([ 0., 2., 4., 6.]), <a list of 3 Patch objects>)
>>> plt.show()

python数据科学中的应用之matplotlib的相关教程结束。

《python 在数据科学中的应用之matplotlib.doc》

下载本文的Word格式文档,以方便收藏与打印。