subplot(nrows, ncols, index, **kwargs)
基础设置:
# 魔法函数,调整画布大小
%pylab inline
pylab.rcParams['figure.figsize'] = (10, 6) # 调整图片大小,长=10,宽=6
fig, axes = plt.subplots(nrows=2, ncols=2)
# fig:可以对整个画布再进行配置
# axes:子画布的信息
ax0, ax1, ax2, ax3 = axes.flatten()
完整example:
# 魔法函数,调整画布大小
%pylab inline
pylab.rcParams['figure.figsize'] = (10, 6) # 调整图片大小,长=10,宽=6
# np.random.seed(19680801)
n_bins = 10
x = np.random.randn(1000, 3)#产生3组1000行的随机生成的标准正态分布的值
fig, axes = plt.subplots(nrows=2, ncols=2)
# fig:可以对整个画布再进行配置
# axes:子画布的信息
ax0, ax1, ax2, ax3 = axes.flatten()
# 第一个子画布
colors = ['red', 'tan', 'lime']