jupytyer[]如何让多张图片显示在一行中

display(img) 默认是一行一张图片

示例代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
from rdkit.Chem import Draw
from rdkit import Chem
mol = Chem.MolFromSmiles('c1cccnc1C')
bi = {}
fp = AllChem.GetMorganFingerprintAsBitVect(mol,nBits=256, radius=2, bitInfo=bi)
pprint(bi)
bits =[19,64,81]
imgs=[]
for bit in bits:
mfp2_svg = Draw.DrawMorganBit(mol, bit, bi)
imgs.append(mfp2_svg)
# display(mfp2_svg)
display(*imgs)

输出:

upload successful

upload successful
upload successful

借助matplotlb 可以实现多张图片显示在一行上面

示例代码

1
2
3
4
5
6

fig, ax = plt.subplots(1,2)
ax[0].set_axis_off()
ax[0].imshow(imgs[0]);
ax[1].set_axis_off()
ax[1].imshow(imgs[1]);

输出:

upload successful
upload successful