matplotlib模块的基础使用

通过调用plot(x , y , ‘ 展现形式 ’)函数,实现数据的可视化,表现为散点图,折线图形式
展现形式处,‘ ’,可在里面填写图线线条表现形式,图形颜色,或者图形展现的格式
其颜色对应图如下:
matplotlib模块的基础使用
其线条格式对应如下图:

matplotlib模块的基础使用
点的形状对应如下图所示:

matplotlib模块的基础使用

颜色,线条,点的形状表现形式可叠加使用

import matplotlib.pylab as pyl
import numpy as py
x = [1,2,3,4,8]
y = [5,7,2,1,5]

pyl.plot(x,y,'--or')
pyl.show()

matplotlib模块的基础使用

当展现形式处为空白时,默认为折线图,当展现形式为‘oc’时,设置为青色散点图,同理。‘–or’为虚线白色散点图

import matplotlib.pylab as pyl
import numpy as py
x = [1,2,3,4,8]
y = [5,7,2,1,5]

pyl.plot(x,y,'--Hr')
pyl.title("mycode")
pyl.xlabel("age")
pyl.xlim(0,10)
pyl.ylim(1,20)
pyl.ylabel("hight")

pyl.show()

plot() 实现图像的绘制
title() 为图像添加标题
xlabel() X轴变量名称
ylabel() Y轴变量名称
xlim(a,b) 设置X轴坐标范围
ylim(a, b) 设置Y轴坐标范围
show() 实现图像的显示

运行程序后,跳出图形界面

matplotlib模块的基础使用