# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
#布局figure 数据subplot
#快捷方式
fig,axes=plt.subplots(2,2,sharex=True,sharey=True)#创建了4个figure对象,x,y轴的值保持一致
for i in range(2):
for j in range(2):
axes[i,j].hist(np.random.randn(500),bins=50,color='r',alpha=1)#axes[i,j] 遍历 是设定图片的位置
plt.subplots_adjust(wspace=0,hspace=0)#左右边界,上下边界
fig.show()
print(axes)
# [[<matplotlib.axes._subplots.AxesSubplot object at 0x000000000B064978>
# <matplotlib.axes._subplots.AxesSubplot object at 0x000000000D0D1CF8>]
# [<matplotlib.axes._subplots.AxesSubplot object at 0x000000000D0FDEF0>
# <matplotlib.axes._subplots.AxesSubplot object at 0x000000000D12C320>]]