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

<pre><code>fig.savefig('mol.jpeg', bbox_inches='tight')
</code></pre>

CC BY-SA 4.0
2018-12-09T18:57:41.933Z
2018-12-09T18:57:41.933Z
Soerendip
<p>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.</p>

<pre><code>%pylab inline
from rdkit import Chem
from rdkit.Chem import Draw

smiles = 'CCC'
m = Chem.MolFromSmiles(smiles)
fig = Draw.MolToMPL(m)
title('Test')
fig.savefig('mol.jpeg')
</code></pre>

<p>Any idea what goes wrong here?</p>

<python>
Rdkit.Chem.Draw.savefig() creates empty figures
# Rdkit.Chem.Draw.savefig() creates empty figures

(Asked by: username_0 on 2018-12-09)

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)
title('Test')
fig.savefig('mol.jpeg')

Any idea what goes wrong here?

**Tags:** python

---

## 1 answers

### Answer by username_0 on 2018-12-09. Score: 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')


---

