Skip to content

Instantly share code, notes, and snippets.

@alexlenail
Last active November 10, 2020 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexlenail/aceec39c5cb789c542a7ea4ba5210c92 to your computer and use it in GitHub Desktop.
Save alexlenail/aceec39c5cb789c542a7ea4ba5210c92 to your computer and use it in GitHub Desktop.
import PIL.Image
from matplotlib.pyplot import imshow
def show(*Ms):
fig, axs = plt.subplots(ncols=len(Ms))
for M, ax in zip(Ms, (axs if type(axs) == list else [axs])):
M = np.atleast_2d(M)
ax.imshow(PIL.Image.fromarray((M - M.min()) * 255 / M.max()))
ax.set_xticks([0, M.shape[1]])
ax.set_yticks([0, M.shape[0]])
for side in ["right","top","bottom","left"]:
ax.spines[side].set_visible(False)
%config InlineBackend.figure_format = 'retina'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment