fnum = len(train_datasets)
plt.figure("show pickle", figsize=(10,10))
j = 0
for set_filename in train_datasets:
print('trying to read pickle: %s ' % set_filename)
try:
with open(set_filename, 'rb') as f:
dataset=pickle.load(f)
except Exception as e:
print('Unable to open pckle file ', set_filename, ':', e)
print ('%d images in total in file %s' % (len(dataset), set_filename))
for i in range(10):
plt.subplot( fnum, 10, 10*j + i + 1)
plt.imshow(dataset[i], cmap='gray');
##去除子图的坐标轴, 对上一个画出的子图起作用
plt.axis('off')
j += 1
##设定子图间距 , left < right, top > bottom, 数字表示窗口大小的比例(如下则子图间距为窗口大小的1%)
plt.subplots_adjust(left=0.04, top= 0.96, right = 0.96, bottom = 0.04, wspace = 0.01, hspace = 0.01)
关于为什么要了left
When using subplots_adjust
, the values of left
, right
, bottom
and top
are to be provided as fractions of the figure width and height. In additions, all values are measured from the left and bottom edges of the figure. This is why right
and top
can't be lower than left
and right
. A typical set-up is: ----- 点击打开参考源