Skip to content

Instantly share code, notes, and snippets.

@steven-mi
Created October 15, 2019 08:38
Show Gist options
  • Save steven-mi/8bc4d685597a10b0b3e9809474d9c2c7 to your computer and use it in GitHub Desktop.
Save steven-mi/8bc4d685597a10b0b3e9809474d9c2c7 to your computer and use it in GitHub Desktop.
pyplot for loop without index
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