Let assume that I have MNIST digits in variable L.
L[0].reshape(28,28)
will give me opportunity to plot this with matplot: plt.matshow(L[0].reshape(28,28))
.
But what if I want to plot 25 digits in 5x5 grid I cannot figure out how to shuffle L[0:24] to draw it properly with matplot.
maybe anyone will have any idea how to do it.
One way to do it would be something like that:
fig, axes = plt.subplots(5,5)
for i, ax in enumerate(axes.ravel()):
ax.imshow(L[i].reshape(28,28))
That way you can loop over your subplots. If you like to shuffle the order of your plots you can use np.random.permutation(25)
this will permute your indices:
fig, axes = plt.subplots(5,5)
for i, ax in zip(np.random.permutation(25), axes.ravel()):
ax.imshow(L[i].reshape(28,28))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.