Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. from matplotlib import pyplot as plt
  2. import numpy as np
  3.  
  4. def show_many(images, max_rows, max_cols, figsize=(20, 20), titles = None, titles_hspace=.1, plot_title = None):
  5. fig = plt.figure(figsize=figsize, dpi=300)
  6.  
  7. for idx, image in enumerate(images):
  8. row = idx // max_cols
  9. col = idx % max_cols
  10.  
  11. ax = plt.subplot2grid((max_rows, max_cols), (row, col))
  12. if titles != None:
  13. ax.set_title(titles[idx])
  14. ax.axis("off")
  15. ax.imshow(image, aspect="auto")
  16.  
  17. if titles == None:
  18. plt.subplots_adjust(wspace=.05, hspace=.05)
  19. else:
  20. plt.subplots_adjust(wspace=.05, hspace=titles_hspace)
  21.  
  22. if plot_title:
  23. plt.suptitle(plot_title)
  24.  
  25. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement