skchem.vis package

Submodules

skchem.vis.atom module

## skchem.vis.atom

Module for atom contribution visualization.

skchem.vis.atom.plot_weights(mol, weights, quality=1, l=0.4, step=50, levels=20, contour_opacity=0.5, cmap='RdBu', ax=None, **kwargs)[source]

Plot weights as a sum of gaussians across a structure image.

Parameters:
  • mol (skchem.Mol) – Molecule to visualize weights for.
  • weights (iterable<float>) – Array of weights in atom index order.
  • l (float) – Lengthscale of gaussians to visualize as a multiple of bond length.
  • step (int) – Size of grid edge to calculate the gaussians.
  • levels (int) – Number of contours to plot.
  • contour_opacity (float) – Alpha applied to the contour layer.
  • ax (plt.axis) – Axis to apply the plot to. Defaults to current axis.
  • cmap (plt.cm) – Colormap to use for the contour.
  • **kwargs – Passed to contourf function.
Returns:

The plot.

Return type:

matplotlib.AxesSubplot

skchem.vis.mol module

## skchem.vis.mol

Module for drawing molecules.

skchem.vis.mol.draw(mol, quality=1, ax=None)[source]

Draw a molecule on a matplotlib axis.

Parameters:
  • mol (skchem.Mol) – The molecule to be drawn.
  • quality (int) – The level of quality. Higher quality takes more time, but will look better (so long as matplotlib’s savefig.dpi is high enough).
  • ax (plt.Axes or None) – An existing axis on which to draw the molecule.
Returns:

A matplotlib AxesImage object with the molecule drawn.

Return type:

plt.AxesImage

skchem.vis.mol.draw_3d(m, conformer_id=-1, label_atoms=None)[source]

Draw a molecule in three dimensions.

Parameters:
  • conformer_id (int) – The id of the conformer to draw.
  • label_atoms (bool) – Whether to label the atoms (this can be toggled in interactive mode):
Returns:

plt.figure

Note

This works great in the notebook with %matplotlib notebook.

Module contents

## skchem.vis

Module for plotting images of molecules.

skchem.vis.draw(mol, quality=1, ax=None)[source]

Draw a molecule on a matplotlib axis.

Parameters:
  • mol (skchem.Mol) – The molecule to be drawn.
  • quality (int) – The level of quality. Higher quality takes more time, but will look better (so long as matplotlib’s savefig.dpi is high enough).
  • ax (plt.Axes or None) – An existing axis on which to draw the molecule.
Returns:

A matplotlib AxesImage object with the molecule drawn.

Return type:

plt.AxesImage

skchem.vis.draw_3d(m, conformer_id=-1, label_atoms=None)[source]

Draw a molecule in three dimensions.

Parameters:
  • conformer_id (int) – The id of the conformer to draw.
  • label_atoms (bool) – Whether to label the atoms (this can be toggled in interactive mode):
Returns:

plt.figure

Note

This works great in the notebook with %matplotlib notebook.

skchem.vis.plot_weights(mol, weights, quality=1, l=0.4, step=50, levels=20, contour_opacity=0.5, cmap='RdBu', ax=None, **kwargs)[source]

Plot weights as a sum of gaussians across a structure image.

Parameters:
  • mol (skchem.Mol) – Molecule to visualize weights for.
  • weights (iterable<float>) – Array of weights in atom index order.
  • l (float) – Lengthscale of gaussians to visualize as a multiple of bond length.
  • step (int) – Size of grid edge to calculate the gaussians.
  • levels (int) – Number of contours to plot.
  • contour_opacity (float) – Alpha applied to the contour layer.
  • ax (plt.axis) – Axis to apply the plot to. Defaults to current axis.
  • cmap (plt.cm) – Colormap to use for the contour.
  • **kwargs – Passed to contourf function.
Returns:

The plot.

Return type:

matplotlib.AxesSubplot