matplotlib 如何使用Rdkit使焊接线更厚

avkwfej4  于 2023-05-18  发布在  其他
关注(0)|答案(1)|浏览(102)

我正在使用RDkit绘制二维分子。我试图使用DrawingOptions.bondLineWidth来控制焊接厚度,但它似乎不起作用(焊接线保持相同的厚度,无论我设置它的值)。你知道吗?

from rdkit.Chem import Draw
from rdkit.Chem.Draw import DrawingOptions
import matplotlib.pyplot as plt

DrawingOptions.atomLabelFontSize = 55
DrawingOptions.dotsPerAngstrom = 100
DrawingOptions.bondLineWidth = 10.0

mol = Chem.MolFromSmiles('CC(C)(C)c1cc(O)ccc1O')
img = Draw.MolToImage(mol, size=(1000, 1000), fitImage=True, kekulize=False, fitWidth=True)
fig, ax = plt.subplots()
ax.imshow(img)
ax.grid(False)
ax.axis('off')
plt.show()
4szc88ey

4szc88ey1#

我在这里发现DrawingOptionsMolToImage弃用并忽略,而支持MolDrawOptions。我更新了代码,这是使用rdkit==2022.9.4

from rdkit import Chem
from rdkit.Chem import Draw
import matplotlib.pyplot as plt

opts = Draw.MolDrawOptions()
opts.bondLineWidth = 5.

mol = Chem.MolFromSmiles('CC(C)(C)c1cc(O)ccc1O')
img = Draw.MolToImage(mol, size=(500, 500), options=opts)
fig, ax = plt.subplots()
ax.imshow(img)
ax.grid(False)
ax.axis('off')
plt.show()

相关问题