2016-07-29 336 views

回答

1

使用plt.figure()的目的是創建一個人物對象。

整個圖形被視爲圖形對象。當我們想要調整圖形的大小以及何時想在一個圖中添加多個Axes對象時,需要明確使用plt.figure()

# in order to modify the size 
fig = plt.figure(figsize=(12,8)) 
# adding multiple Axes objects 
fig, ax_lst = plt.subplots(2, 2) # a figure with a 2x2 grid of Axes 

Parts of a Figure

2

這並不總是必要的,因爲在創建scatter圖時隱含創建figure;但是,在您顯示的情況下,將使用plt.figure明確創建該數字,以便該數字爲特定大小而非默認大小。

另一種選擇是使用gcf創建scatter劇情後獲得當前的數字和追溯設置數字大小:

# Create scatter plot here 
plt.gcf().set_size_inches(10, 8)