[英]How can I plot 4000 images line by line in jupyter notebook?
我想逐行绘制 4000 个图像作为子图或使用其他方法。 当我使用 subplot 方法时,显示的图像大小以某种方式减小。 我想解决这个问题并了解导致绘图尺寸减小的原因,或者学习其他绘制图像的方法。
for ix in range(0, len(preds_train_t)):
fig = plt.figure()
#ix = random.randint(0, len(preds_train_t))
fig.add_subplot(ix+1, 3, 1)
plt.imshow(np.dstack((X_train[ix],X_train[ix],X_train[ix])))
tmp = np.squeeze(Y_train[ix]).astype(np.float32)
fig.add_subplot(ix+1, 3, 2)
plt.imshow(np.dstack((tmp,tmp,tmp)))
tmp = np.squeeze(preds_train_t[ix]).astype(np.float32)
fig.add_subplot(ix+1, 3, 3)
plt.imshow(np.dstack((tmp,tmp,tmp)))
plt.show()
Jupyter 笔记本的结果:
for ix in range(0, len(preds_train_t)):
fig = plt.figure()
#ix = random.randint(0, len(preds_train_t))
fig.add_subplot(1, 3, 1)
plt.imshow(np.dstack((X_train[ix],X_train[ix],X_train[ix])))
tmp = np.squeeze(Y_train[ix]).astype(np.float32)
fig.add_subplot(1, 3, 2)
plt.imshow(np.dstack((tmp,tmp,tmp)))
tmp = np.squeeze(preds_train_t[ix]).astype(np.float32)
fig.add_subplot(1, 3, 3)
plt.imshow(np.dstack((tmp,tmp,tmp)))
plt.show()
我已将“ix+1”更改为“1”,问题已解决,因为 for 循环导致 jupyter notebook 中的新行用于绘图。
如果您正在寻找在笔记本中绘制图像的更快、更有效的方法,您应该考虑使用ipyplot
import ipyplot
ipyplot.plot_images(X_train, img_width=150)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.