---
title: "MoleculePlot"
language: "en"
type: "Symbol"
summary: "MoleculePlot[mol] creates a two-dimensional structure diagram of the molecule mol. MoleculePlot[mol, patt] creates a diagram of mol where all atoms and bonds matching the pattern patt are highlighted."
keywords: 
- 2D molecule plot
- chemical structure
- chemistry
- Lewis structure
- molecular computation
- molecular graphics
- molecular visualization
- molecule
- structural depiction
- structural diagram
- structure diagram
canonical_url: "https://reference.wolfram.com/language/ref/MoleculePlot.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Physics & Chemistry: Data and Computation"
    link: "https://reference.wolfram.com/language/guide/PhysicsAndChemistryDataAndComputation.en.md"
  - 
    title: "Molecular Structure & Computation"
    link: "https://reference.wolfram.com/language/guide/MolecularStructureAndComputation.en.md"
---
[EXPERIMENTAL]

# MoleculePlot

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

MoleculePlot[mol, patt] 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.

* ``mol`` can be a ``Molecule`` object or something that can be easily converted to one, such as a systematic chemical name, a ``"Chemical"`` entity, a ``BioSequence`` or an ``ExternalIdentifier``.

* ``MoleculePlot[MoleculePattern[…]]`` will return a depiction of the given molecule pattern.

* Possible forms for ``patt`` include:

|                         |                                       |
| ----------------------- | ------------------------------------- |
| n                       | the index of a particular atom        |
| Atom[…]                 | a pattern for an atom                 |
| Bond[…]                 | a pattern for a bond                  |
| MoleculePattern[…]      | a pattern for a molecule substructure |
| {patt1, patt2, …}       | a list of patterns                    |
| <\|label1 -> patt1, …\|> | an Association of labels and patterns |

* ``MoleculePlot`` has the same options as ``Graphics``, with the following additions and changes: []

|                  |             |                                                                                      |
| ---------------- | ----------- | ------------------------------------------------------------------------------------ |
| AtomLabels       | Automatic   | labels and label placements for atoms                                                |
| AtomLabelStyle   | Automatic   | style to use for atom labels                                                         |
| BondLabels       | None        | labels and label placements for bonds                                                |
| BondLabelStyle   | Automatic   | style to use for bond labels                                                         |
| ColorRules       | Automatic   | a list of rules {elem1 -> col1, …} dictating which colors to use for atomic elements |
| IncludeHydrogens | Automatic   | whether to show hydrogen atoms                                                       |
| PlotLegends      | None        | legends for highlights                                                               |
| PlotTheme        | \$PlotTheme | overall theme for the plot                                                           |

* Supported plot themes include:

|         |              |                                                                      |
| ------- | ------------ | -------------------------------------------------------------------- |
| [image] | "AllAtom"    | display all hydrogens                                                |
| [image] | "Aromatic"   | aromatic bonds are shown as dashed lines or circles                  |
| [image] | "HeavyAtom"  | hydrogen atoms are elided or combined with the connected heavy atom  |
| [image] | "Monochrome" | all text and graphics are shown in black                             |

* Typical settings for ``PlotLegends`` include:

|                  |                                    |
| ---------------- | ---------------------------------- |
| None             | no legend                          |
| Automatic        | automatically determine legend     |
| {lbl1, lbl2, …}  | use lbl1, lbl2, … as legend labels |
| Placed[lspec, …] | specify placement for legend       |

### List of all options

|                        |                 |                                                                                      |
| ---------------------- | --------------- | ------------------------------------------------------------------------------------ |
| AlignmentPoint         | Center          | the default point in the graphic to align with                                       |
| AspectRatio            | Automatic       | ratio of height to width                                                             |
| AtomLabels             | Automatic       | labels and label placements for atoms                                                |
| AtomLabelStyle         | Automatic       | style to use for atom labels                                                         |
| Axes                   | False           | whether to draw axes                                                                 |
| AxesLabel              | None            | axes labels                                                                          |
| AxesOrigin             | Automatic       | where axes should cross                                                              |
| AxesStyle              | {}              | style specifications for the axes                                                    |
| Background             | None            | background color for the plot                                                        |
| BaselinePosition       | Automatic       | how to align with a surrounding text baseline                                        |
| BaseStyle              | {}              | base style specifications for the graphic                                            |
| BondLabels             | None            | labels and label placements for bonds                                                |
| BondLabelStyle         | Automatic       | style to use for bond labels                                                         |
| ColorRules             | Automatic       | a list of rules {elem1 -> col1, …} dictating which colors to use for atomic elements |
| ContentSelectable      | Automatic       | whether to allow contents to be selected                                             |
| CoordinatesToolOptions | Automatic       | detailed behavior of the coordinates tool                                            |
| Epilog                 | {}              | primitives rendered after the main plot                                              |
| FormatType             | TraditionalForm | the default format type for text                                                     |
| Frame                  | False           | whether to put a frame around the plot                                               |
| FrameLabel             | None            | frame labels                                                                         |
| FrameStyle             | {}              | style specifications for the frame                                                   |
| FrameTicks             | Automatic       | frame ticks                                                                          |
| FrameTicksStyle        | {}              | style specifications for frame ticks                                                 |
| GridLines              | None            | grid lines to draw                                                                   |
| GridLinesStyle         | {}              | style specifications for grid lines                                                  |
| ImageMargins           | 0.              | the margins to leave around the graphic                                              |
| ImagePadding           | All             | what extra padding to allow for labels etc.                                          |
| ImageSize              | Automatic       | the absolute size at which to render the graphic                                     |
| IncludeHydrogens       | Automatic       | whether to show hydrogen atoms                                                       |
| LabelStyle             | {}              | style specifications for labels                                                      |
| Method                 | Automatic       | details of graphics methods to use                                                   |
| PlotLabel              | None            | an overall label for the plot                                                        |
| PlotLegends            | None            | legends for highlights                                                               |
| PlotRange              | All             | range of values to include                                                           |
| PlotRangeClipping      | False           | whether to clip at the plot range                                                    |
| PlotRangePadding       | Automatic       | how much to pad the range of values                                                  |
| PlotRegion             | Automatic       | the final display region to be filled                                                |
| PlotTheme              | \$PlotTheme     | overall theme for the plot                                                           |
| PreserveImageOptions   | Automatic       | whether to preserve image options when displaying new versions of the same graphic   |
| Prolog                 | {}              | primitives rendered before the main plot                                             |
| RotateLabel            | True            | whether to rotate y labels on the frame                                              |
| Ticks                  | Automatic       | axes ticks                                                                           |
| TicksStyle             | {}              | style specifications for axes ticks                                                  |

---

## Examples (11)

### Basic Examples (2)

Create a molecule and plot it:

```wl
In[1]:= MoleculePlot[Molecule["NC(=O)C[C@H](C(=O)O)N"]]

Out[1]= [image]
```

Highlight the first and third atoms:

```wl
In[2]:= MoleculePlot[Molecule["NC(=O)C[C@H](C(=O)O)N"], {3, 8}]

Out[2]= [image]
```

Highlight all oxygen atoms:

```wl
In[3]:= MoleculePlot[Molecule["NC(=O)C[C@H](C(=O)O)N"], Atom["O"]]

Out[3]= [image]
```

---

Highlight two different patterns:

```wl
In[1]:= MoleculePlot["O=C(C1CCC1)S[C@@H]1CCC1(C)C", <|"carbonyl" -> Bond[{"C", "O"}, "Double"], "ring carbons" -> Atom["C", "RingAtomQ" -> True]|>]

Out[1]= [image]
```

### Scope (2)

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

```wl
In[1]:=
m = Molecule[{Atom["C"], Atom["C"], Atom["C"], Atom["O"], Atom["N"], Atom["C"], Atom["O"], Atom["N"], 
  Atom["C"], Atom["C"], Atom["C"], Atom["O"], Atom["O"], Atom["C"], Atom["N"], Atom["C"], 
  Atom["C"], Atom["O"], Atom["O"], Atom["C"], Atom["C"], A ... er" -> 10, "Direction" -> "Clockwise", "FiducialAtom" -> 9, 
    "Ligands" -> {11, 5, 34}], Association["StereoType" -> "Tetrahedral", "ChiralCenter" -> 16, 
    "Direction" -> "Counterclockwise", "FiducialAtom" -> 15, "Ligands" -> {17, 20, 40}]}];
carbonylPattern = Bond[{"C", "O"}, "Double"];
```

Highlight each carbonyl separately:

```wl
In[2]:= MoleculePlot[m, carbonylPattern]

Out[2]= [image]
```

Highlight each carbonyl as a single color:

```wl
In[3]:= MoleculePlot[m, {carbonylPattern}]

Out[3]= [image]
```

---

Highlight several patterns:

```wl
In[1]:=
m = Molecule[{Atom["C"], Atom["N"], Atom["C"], Atom["C"], Atom["C"], Atom["N"], Atom["C"], Atom["O"], 
  Atom["C"], Atom["C"], Atom["C"], Atom["C"], Atom["H"], Atom["H"], Atom["H"], Atom["H"], 
  Atom["H"], Atom["H"], Atom["H"], Atom["H"], Atom["H"], A ... e"], 
  Bond[{6, 22}, "Single"], Bond[{10, 23}, "Single"], Bond[{10, 24}, "Single"], 
  Bond[{11, 25}, "Single"], Bond[{11, 26}, "Single"], Bond[{11, 27}, "Single"], 
  Bond[{12, 28}, "Single"], Bond[{12, 29}, "Single"], Bond[{12, 30}, "Single"]}];

In[2]:= MoleculePlot[m, {1, Bond[{"C", "C"}, "Double"]}]

Out[2]= [image]
```

### Options (7)

#### AtomLabels (1)

Label all atoms by their index:

```wl
In[1]:= MoleculePlot[Molecule["2,3-dichloro-4-nitro-1H-pyrrole"], AtomLabels -> "AtomIndex"]

Out[1]= [image]
```

Label only chlorine atoms by their index:

```wl
In[2]:= MoleculePlot[Molecule["2,3-dichloro-4-nitro-1H-pyrrole"], AtomLabels -> {Atom["Cl"] -> "AtomIndex"}]

Out[2]= [image]
```

Label non-hydrogen atoms by their hybridization:

```wl
In[3]:= MoleculePlot[Molecule["2,3-dichloro-4-nitro-1H-pyrrole"], AtomLabels -> {Atom[Except["H"]] -> MoleculeProperty["OrbitalHybridization"]}]

Out[3]= [image]
```

#### AtomLabelStyle (1)

Set all labels to have the same style:

```wl
In[1]:= MoleculePlot[Molecule["2,3-dichloro-4-nitro-1H-pyrrole"], AtomLabels -> "AtomIndex", AtomLabelStyle -> Directive[FontSize -> 12, Blue]]

Out[1]= [image]
```

Set the label style depending on atom type:

```wl
In[2]:= MoleculePlot[Molecule["2,3-dichloro-4-nitro-1H-pyrrole"], AtomLabels -> "AtomIndex", AtomLabelStyle -> {Atom["C"] -> Directive[12, Blue], Atom["O"] -> Directive[8, Purple, Bold], _ -> Italic}]

Out[2]= [image]
```

#### BondLabels (1)

Label all bonds by their index:

```wl
In[1]:= MoleculePlot[Molecule["2,3-dichloro-4-nitro-1H-pyrrole"], BondLabels -> "BondIndex"]

Out[1]= [image]
```

Label only bonds to chlorine atoms by their bond type:

```wl
In[2]:= MoleculePlot[Molecule["2,3-dichloro-4-nitro-1H-pyrrole"], BondLabels -> {Bond[{"Cl", _}] -> MoleculeProperty["BondType"]}]

Out[2]= [image]
```

#### BondLabelStyle (1)

Give all bond labels the same style:

```wl
In[1]:= MoleculePlot[Molecule["2,3-dichloro-4-nitro-1H-pyrrole"], BondLabels -> "BondIndex", BondLabelStyle -> Directive[FontSize -> 22, Red]]

Out[1]= [image]
```

Label bonds differently based on their atoms:

```wl
In[2]:= MoleculePlot[Molecule["2,3-dichloro-4-nitro-1H-pyrrole"], BondLabels -> "BondIndex", BondLabelStyle -> {Bond[{"N", _}] -> Directive[FontSize -> 22, Red], Bond[{"Cl", _}] -> Directive[FontSize -> 22, Blue]}]

Out[2]= [image]
```

#### ColorRules (1)

Specify different colors for atomic elements:

```wl
In[1]:= MoleculePlot["Nc1nccc(n1)c1c(C)onc1c1ccccc1", ColorRules -> {"C" -> RGBColor[0.79, 0.34, 0.5], "N" -> RGBColor[0.5, 0.51, 0.81], _ -> Black}]

Out[1]= [image]
```

#### PlotLegends (1)

Use placeholders for plot legends:

```wl
In[1]:=
m = Molecule[{Atom["C"], Atom["N"], Atom["C"], Atom["C"], Atom["C"], Atom["N"], Atom["C"], Atom["O"], 
  Atom["C"], Atom["C"], Atom["C"], Atom["C"], Atom["H"], Atom["H"], Atom["H"], Atom["H"], 
  Atom["H"], Atom["H"], Atom["H"], Atom["H"], Atom["H"], A ... e"], 
  Bond[{6, 22}, "Single"], Bond[{10, 23}, "Single"], Bond[{10, 24}, "Single"], 
  Bond[{11, 25}, "Single"], Bond[{11, 26}, "Single"], Bond[{11, 27}, "Single"], 
  Bond[{12, 28}, "Single"], Bond[{12, 29}, "Single"], Bond[{12, 30}, "Single"]}];

In[2]:= MoleculePlot[m, {1, Bond[{"C", "C"}, "Double"]}, PlotLegends -> Automatic]

Out[2]= [image]
```

Use the expressions to label the highlights:

```wl
In[3]:= MoleculePlot[m, {1, Bond[{"C", "C"}, "Double"]}, PlotLegends -> Placed["Expressions", Below]]

Out[3]= [image]
```

#### 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:

```wl
In[1]:= MoleculePlot["Nc1nccc(n1)c1c(C)onc1c1ccccc1", PlotTheme -> "Aromatic"]

Out[1]= [image]
```

Combine different plot themes:

```wl
In[2]:= MoleculePlot["Nc1nccc(n1)c1c(C)onc1c1ccccc1", PlotTheme -> {"Aromatic", "AllAtom", "Monochrome"}]

Out[2]= [image]
```

## See Also

* [`MoleculePlot3D`](https://reference.wolfram.com/language/ref/MoleculePlot3D.en.md)
* [`Molecule`](https://reference.wolfram.com/language/ref/Molecule.en.md)
* [`MoleculeRecognize`](https://reference.wolfram.com/language/ref/MoleculeRecognize.en.md)
* [`AtomLabels`](https://reference.wolfram.com/language/ref/AtomLabels.en.md)
* [`AtomLabelStyle`](https://reference.wolfram.com/language/ref/AtomLabelStyle.en.md)
* [`BondLabels`](https://reference.wolfram.com/language/ref/BondLabels.en.md)
* [`BondLabelStyle`](https://reference.wolfram.com/language/ref/BondLabelStyle.en.md)
* [`Chemical`](https://reference.wolfram.com/language/ref/entity/Chemical.en.md)
* [`Protein`](https://reference.wolfram.com/language/ref/entity/Protein.en.md)

## Related Guides

* [Physics & Chemistry: Data and Computation](https://reference.wolfram.com/language/guide/PhysicsAndChemistryDataAndComputation.en.md)
* [Molecular Structure & Computation](https://reference.wolfram.com/language/guide/MolecularStructureAndComputation.en.md)

## History

* [Introduced in 2019 (12.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn120.en.md) \| [Updated in 2021 (13.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn130.en.md)