2016-03-07 50 views
1

如何顯示到次要情節與IPython.display圖像列表?使用IPython.display將圖像排列到子圖中?

我用下面的代碼:

from IPython.display import Image 
from IPython.display import display 

x1 = Image(url='http://image1.png',width=100,height=100) 
x2 = Image(url='http://image2.png',width=100,height=100) 
x3 = Image(url='http://image3.png',width=100,height=100) 
x4 = Image(url='http://image4.png',width=100,height=100) 

display(x1,x2,x3,x4) 

它顯示了4個圖像垂直於IPython的筆記本電池。

我想他們被佈置成2×2陣列。

+1

IPython都沒有內置工具,在網格中顯示圖像。你要麼需要使用像matplotlib或PIL它們合併成一個圖像,或構建HTML如你所願,並顯示給他們佈置。 –

+0

我明白了。謝謝。我會檢查出PIL。 –

回答

0

我建議你使用subplotmatplotlib.pyplot。要顯示圖像,請使用imshow函數。

1

如果不是要求顯示代碼單元格內的圖像,你可以使用降價表中的一個降價單元格中顯示錶格格式的圖像。

| Col header A     | Col header B     | 
|:-----------------------------:|:-----------------------------:| 
| <img src="http://image1.png"> | <img src="http://image2.png"> | 
| <img src="http://image3.png"> | <img src="http://image4.png"> | 

Outcome