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已經存在, 則清空