import matplotlib.pyplot as plt
pyplot模块
plt.ion()
:打开交互模式plt.figure(num=None, figsize=None, dpi=None,
facecolor=None, edgecolor=None, frameon=True,
FigureClass=<class 'matplotlib.figure.Figure'>, **kwargs)
参数:
num:整数或者字符串,默认值是None。figure对象的id。如果没有指定num,那么会创建新的figure,id(也就是数量)会递增,这个id存在figure对象的成员变量number中;如果指定了num值,那么检查id为num的figure是否存在,存在的话直接返回,否则创建id为num的figure对象,并且如果num是字符串类型,窗口的标题会设置成num。
fsize:整数元组,默认值是None。表示宽、高的inches数。
dpi:整数,默认值为None。表示figure的分辨率
facecolor:背景颜色
edgecolor:边缘颜色
返回:
figure:Figure对象ax = plt.subplot(*args, **kwargs)
:
关键字参数:
facecolor:subplot的背景颜色
projection:
返回:
subplot(nrows, nclos, plot_number)#将figure划分成nrows行ncols列个子坐标。plot_number用来返回指定的subplot,从1开始,先横向后纵向
#当行、列和plot_number都小于10的时候,可以用下面的简单的调用形式来指定行列数及plot_number
subplot(211)
例子:
import matplotlib.pyplot as plt
# plot a line, implicitly creating a subplot(111)
plt.plot([1,2,3])
# now create a subplot which represents the top plot of a grid with 2 rows and 1 column.
#Since this subplot will overlap the
# first, the plot (and its axes) previously created, will be removed
plt.subplot(211)
plt.plot(range(12))
plt.subplot(212, facecolor='y') # creates 2nd subplot with yellow background
fig, ax = plt.subplots(nrows=1, ncols=1, sharex=False,
sharey=False, squeeze=Tru