matplotlib.pyplot.plot(*args, scalex=True, scaley=True,data=None,**kwargs)
用线段和标记去绘制x和y。调用签名:
plot([x], y, [fmt], *, data=None, **kwargs)
plot([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)
点或线的坐标由x, y给出
操作参数 fmt 是为了方便设置基础格式: color, marker and linestyle
,是一种快捷的字符表示法
plot(x, y) # 绘制 x 和 y 通过默认的线段和颜色
plot(x, y, 'bo') # 绘制x 和 y 使用蓝圆圈标志
plot(y) #绘制y , x 使用数组 0.......N-1
plot(y, 'r+') # 同上, 使用红色加号
你可以使用二维线段 配置 作为关键参数来控制更多地显示,线面两行代码展示同样的效果:
plot(x, y, 'go--', linewidth=2, markersize=12)
plot(x, y, color='green', marker='o', linestyle='dashed',linewidth=2, markersize=12)
可以绘制多个数据集
plot(x1, y1, 'bo')
plot(x2, y2, 'go')
参数介绍:
x, y 类数组 或者 标量
通常为一维数组
关键参数不能省
fmt 字符, 操作符 (可选)
线段格式, 颜色格式 ‘ro’
只是快捷地设置属性, 可以用keywords 参数替换
fmt = ‘[marker][line][color]’
data 可选
returns: lines
Other Parameters : scalex, scaley: 可选
**kwargs: 二维线段 可选
matplotlib.pyplot.figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True, FigureClass=, clear=False, *kwargs)
parameters :
num: 整型或者字符串, 可选, 默认:None
如果没有提供, 自动创建一个, 如果提供了, 如果这个id的已经存在, 则激活这个figure, 返回一个引用, 如果不存在就创建一个,如果是一个字符串, 会当成这个figure 的title,
figsize:(float, float),可选, unit 英寸, 默认[6.4, 4.8]
dpi: integer, 可选, default:None, 默认 :100.0
facecolor: 背景色, 默认‘white’
edgecolor: border color
frameon: bool, 可选, default: True,
如果False , 禁止绘制
FigureClass: subclass of Figure
clear: bool, optional, default:False
如果是True, 如果figure已经存在, 则清空