def mkfig(ims, subtitle='Images'):
    fig = plt.figure()
    if type(ims) == np.ndarray:
        fig.imshow(ims, cmap=plt.cm.gray, interpolation='nearest')
    else:
        ims = list(ims)
        n = len(ims)
        rows = math.floor(math.sqrt(n))
        cols = math.ceil(n / float(rows))
        for i, im in enumerate(ims):
            plt.subplot(rows, cols, i + 1)
            plt.imshow(im, cmap=plt.cm.gray,
                       interpolation='nearest')
            plt.xticks(())
            plt.yticks(())
        plt.suptitle(subtitle, fontsize=16)
    return fig
dataset/ETHPy150Open dfdx/masque/masque/utils.py/mkfig/original