python使用pylab一幅图片画多个图

import numpy as np
import pylab as pl

if __name__ == '__main__':
fig = pl.figure(figsize=(10, 5))
ax = fig.add_subplot(121)
toplot = np.random.randint(0, 255, [40, 40])
pl.text(1, 3, 'Left picture', fontsize=20)
pl.imshow(toplot)
ax = fig.add_subplot(122)
toplot = np.random.randint(0, 2, [40, 40])
pl.text(1, 3, 'Right picture', fontsize=20)
pl.imshow(toplot)
pl.savefig('image_%d.png' % 0)
原文地址:https://www.cnblogs.com/iuyy/p/14063787.html