我想在iPython中并排显示2个PNG图像。
我要做的代码是:
from IPython.display import Image, HTML, display
img_A = '\path\to\img_A.png'
img_B = '\path\to\img_B.png'
display(HTML("<table><tr><td><img src=img_A></td><td><img src=img_B></td></tr></table>"))
Run Code Online (Sandbox Code Playgroud)
但是它不输出图像,而只显示两个图像的占位符:
我也尝试了以下方法:
s = """<table>
<tr>
<th><img src="%s"/></th>
<th><img src="%s"/></th>
</tr></table>"""%(img_A, img_B)
t=HTML(s)
display(t)
Run Code Online (Sandbox Code Playgroud)
但是结果是一样的:
这些图像肯定在路径中,因为我通过在弹出窗口中显示它们进行了验证:
plt.imshow(img_A)
plt.imshow(img_B)
Run Code Online (Sandbox Code Playgroud)
并且它们确实出现在弹出窗口中。
如何在iPython中并排显示2张图像?