Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from matplotlib import pyplot as plt
- import numpy as np
- def show_many(images, max_rows, max_cols, figsize=(20, 20), titles = None, titles_hspace=.1, plot_title = None):
- fig = plt.figure(figsize=figsize, dpi=300)
- for idx, image in enumerate(images):
- row = idx // max_cols
- col = idx % max_cols
- ax = plt.subplot2grid((max_rows, max_cols), (row, col))
- if titles != None:
- ax.set_title(titles[idx])
- ax.axis("off")
- ax.imshow(image, aspect="auto")
- if titles == None:
- plt.subplots_adjust(wspace=.05, hspace=.05)
- else:
- plt.subplots_adjust(wspace=.05, hspace=titles_hspace)
- if plot_title:
- plt.suptitle(plot_title)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement