I can draw a molecule in a jupyter notebook with RDKit. Though, when I use the savefig() method only a white canvas is saved. No molecule is saved.

%pylab inline
from rdkit import Chem
from rdkit.Chem import Draw

smiles = 'CCC'
m = Chem.MolFromSmiles(smiles)
fig = Draw.MolToMPL(m)

Any idea what goes wrong here?


1 Answer 1


For some reason you have to set bbox_inches to tight. Without that rdkit does not fit the molecule into the canvas and might plot an empty figure.

fig.savefig('mol.jpeg', bbox_inches='tight')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.