plt.figure()函数
matplotlib.pyplot.figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True,
FigureClass=<class 'matplotlib.figure.Figure'>, clear=False, **kwargs)
num:int or str,figure的唯一编号。不指定调用figure时就会默认从1增加自动传入int。
import numpy as np
import pandas as pd
from pandas import Series,DataFrame
import matplotlib.pyplot as plt
t=np.arange(0.0,2.0,0.01)
s1=np.sin(2*np.pi*t)
s2=np.sin(4*np.pi*t)
plt.figure(1,figsize=(6,4.5),facecolor='y',edgecolor='g')
plt.subplot(211)
plt.plot(t,s1)
plt.subplot(212)
plt.plot(t,2*s1)
plt.tight_layout()
#创建第二个figure
plt.figure(2)
plt.plot(t,s2)
[<matplotlib.lines.Line2D at 0x1d34db03608>]
#修改figure(1)
plt.figure(1)
plt.subplot(211)
plt.plot(t,s2,'-g*')
ax=plt.gca()
ax.set_xticklabels([])
plt.show()