Created
July 27, 2020 03:59
-
-
Save sizhky/7200d21681fe9afcf316ae40b375e4bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def subplots(ims, nc=5, figsize=(5,5), **kwargs): | |
if len(ims) == 0: return | |
titles = kwargs.pop('titles',[None]*len(ims)) | |
nr = (len(ims)//nc) if len(ims)%nc==0 else (1+len(ims)//nc) | |
logger.info(f'plotting {len(ims)} images in a grid of {nr}x{nc} @ {figsize}') | |
fig, axes = plt.subplots(nr,nc,figsize=figsize) | |
axes = axes.flat | |
for ix,(im,ax) in enumerate(zip(ims,axes)): | |
show(im, ax=ax, title=titles[ix], **kwargs) | |
blank = (np.eye(100) + np.eye(100)[::-1]) | |
for ax in axes: show(blank, ax=ax) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment