creates a two-dimensional structure diagram of the molecule mol.


creates a diagram of mol where all atoms and bonds matching the pattern patt are highlighted.

Details and Options

  • MoleculePlot returns a Graphics expression.
  • If the molecule does not have structure diagram coordinates, they will be generated automatically.
  • Possible values for patt include any atom, bond or molecular pattern as recognized by FindMoleculeSubstructure.
  • MoleculePlot has the same options as Graphics, with the following additions and changes:
  • ColorRulesAutomatica list of rules {elem1->col1,} dictating which colors to use for atomic elements
    PlotLegendsNonelegends for highlights
    PlotTheme$PlotThemeoverall theme for the plot
  • Supported plot themes include:
  • "AllAtom"display all hydrogens
    "Aromatic"aromatic bonds are shown as dashed lines or circles
    "HeavyAtom"hydrogen atoms are elided or combined with the connected heavy atom
    "Monochrome"all text and graphics are shown in black
  • Typical settings for PlotLegends include:
  • Noneno legend
    Automaticautomatically determine legend
    {lbl1,lbl2,}use lbl1, lbl2, as legend labels
    Placed[lspec,]specify placement for legend


open allclose all

Basic Examples  (1)

Create a molecule and plot it:

Highlight all carbon-sulfur bonds:

Highlight two different patterns:

Apply different styling to patterns:

Scope  (2)

A pattern can match one or multiple positions in a molecule:

Highlight each carbonyl separately:

Highlight each carbonyl as a single color:

Highlight several patterns:

Options  (3)

ColorRules  (1)

Specify different colors for atomic elements:

PlotLegends  (1)

Use placeholders for plot legends:

Use the expressions to label the highlights:

PlotTheme  (1)

By default, aromatic bonds are shown in their delocalized Kekule form. Use the "Aromatic" plot theme to show which bonds are aromatic.

Phenyl rings are shown with a circle to indicate the delocalized bonding electrons. Aromatic heterocycles use dashed lines for aromatic bonds:

Combine different plot themes:

Introduced in 2019