matplotlib的基本用法 Figure

2021-09-14 06:38:17 字數 1375 閱讀 3802

def figure(num=none, figsize=none, dpi=none, facecolor=none, edgecolor=none, frameon=true, figureclass=figure, clear=false, **kwargs)

num:如果此引數沒有提供,則乙個新的figure物件將被建立,同時增加figure的計數數值,此數值被儲存在figure物件的乙個數字屬性當中。如果有此引數,且存在對應id的figure物件,則啟用對於id的figure物件。如果對應id的figur物件不存在,則建立它並返回它。如果num的值是字串,則將視窗標題設定為此字串。

例:

#指定figure的編號並指定figure的大小, 指定線的顏色, 寬度和型別

注意:如果你建立了多個figure例項,必須確保你顯式的呼叫「close」來釋放你已經不再使用的figure例項。因為只有這樣pylab才能正確的釋放記憶體

matplotlib基本用法

繪製散點圖 修改顏色,rgb 紅綠藍,預設為藍 plt.plot x,y,修改線的形狀為虛線,預設為折線 另外 o 為點,為三角 plt.plot x,y,g 一起修改為綠色虛線 plt.axis 1 6,0 5 修改座標軸刻度顯示 前兩個是x的範圍,後兩個是y的範圍 plt.plot x,y 在處...

matplotlib基本用法

折線圖繪製 plt.plot plt.plot大小和解析度 fig plt.figure figsize 20,8 dpi 80 xy軸上的刻度和字串以及刻度稀疏和密集的問題 調整x軸的刻度 x list x xtick labeles 歲 format i for i in x 取步長,數字和字串...

matplotlib的學習2 基本用法

import matplotlib.pyplot as plt import numpy as np x np.linspace 1,1,50 範圍 1 到 1,個數是50 y 2 x 1 使用plt.figure定義乙個影象視窗.使用plt.plot畫 x y 曲線.使用plt.show顯示影象....