【发布时间】:2021-01-06 05:26:40
【问题描述】:
我正在尝试打印与 jupyter 笔记本单元格中的每个图像相对应的文本。下面是一个虚拟代码块:
#paths = list of image paths; say 10 image-paths
#document_text = list of strings as long as 200 words corresponding each image. say 10 strings
%matplotlib inline
import matplotlib.pylplot as plt
from PIL import Image
for path,text in enumerate(paths,document_text):
print(document_text)
img = Image.open(path)
plt.imshow(img)
代码块工作正常,但有一个小故障。打印所有打印语句,然后显示所有图像,即 10 ~ 200 个单词字符串后跟 10 个图像。我想要的是一张印刷品,然后是相应的图像。如何做到这一点?我不想使用 plt.title() 因为字符串很长。
【问题讨论】:
标签: python for-loop matplotlib printing jupyter-notebook