1

I am using RDkit to draw a molecule in 2D. I am trying to use DrawingOptions.bondLineWidth to control the bond thickness but it doesn't seem to be working (the bond lines remain the same thickness regardless of the value I set it to). Any idea?

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()
Julep
  • 760
  • 1
  • 6
  • 18
  • It SHOULD be the same thing, but I suggest you remove your second import and just do `Draw.DrawingOptions.bondLineWidth`. – Tim Roberts May 10 '23 at 17:50

1 Answers1

2

I found out here that DrawingOptions is deprecated and ignored by MolToImage in favour of MolDrawOptions. I updated the code, this is working with 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()
Julep
  • 760
  • 1
  • 6
  • 18