Created
October 15, 2019 08:38
-
-
Save steven-mi/8bc4d685597a10b0b3e9809474d9c2c7 to your computer and use it in GitHub Desktop.
pyplot for loop without index
This file contains 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
plt.figure(figsize=(20, 20)) | |
num_classes = 10 | |
for c in range(num_classes): | |
# Select samples_per_class random keys of the labels == current class | |
keys = np.random.choice(np.where(label == c)[0], examples_each_row) | |
images = data[keys] | |
labels = label[keys] | |
for i in range(examples_each_row): | |
f = plt.subplot(examples_each_row, num_classes, i * num_classes + c + 1) | |
f.axis('off') | |
plt.imshow(images[i], cmap='gray', interpolation='nearest') | |
plt.title(labels[i]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment