How to Measure Distances and Angles in PyMOL: Complete Guide
Every structural biology paper reports distances — H-bond lengths, active site geometries, domain separations. PyMOL makes these measurements trivial once you know the right commands and how to display them cleanly in publication figures.
Two ways to measure: wizard vs command
- Click atoms directly in the 3D viewer
- Instant visual feedback
- No need to know atom names
- Good for quick one-off measurements
- Access: Wizard menu → Measurement
- Specify exact atoms by name in the command line
- Scriptable — include in .pml files
- Reproducible — same measurement every run
- Supports H-bond detection (mode=2)
- Can measure many atom pairs at once
The distance wizard — click to measure
The fastest way to measure a distance when you’re working interactively and don’t know the exact atom names. Access it from the menu: Wizard → Measurement. The wizard appears in the right panel with four measurement types — distance, angle, dihedral, and H-bond. Select Distance, then click two atoms in the viewer. PyMOL draws a dashed line between them and displays the distance in ångströms.
- Click the first atom — it highlights in pink
- Click the second atom — the distance appears as a dashed line with a label
- Click New Measurement in the wizard panel to start another measurement without clearing the previous one
- Click Done when finished — this exits the wizard but keeps all measurements visible
show sticks for the region of interest makes individual atoms much easier to target.
The distance command — precise and scriptable
The distance command creates a named measurement object between any two selections — individual atoms, residues, or entire selections (in which case it finds the closest atoms between them).
# Basic syntax
distance name, selection1, selection2 [, cutoff] [, mode]
# Simple examples
distance d1, resi 185 and name OG, resn LIG and name O3
# Distance between two residues (finds closest atoms between them)
distance gap, resi 50, resi 200
# Named measurement — appears in object list, reusable
distance catalytic_dist, resi 35 and name NE2, resi 57 and name SG
# Distance with cutoff (only show pairs within 3.5 Å)
distance close_contacts, LIG, pocket, 3.5
Understanding atom identifiers
Precise distance measurements require knowing how to specify exactly which atom you mean. PyMOL uses a hierarchical identifier:
In practice, you rarely need the full identifier. A selection expression like resi 185 and name OG and chain A is cleaner, equally precise, and more readable in scripts. The full slash-separated format is most useful when you have multiple loaded structures with the same residue numbers and need to distinguish them unambiguously.
iterate (resi 185 and chain A), print(name) to list all atom names in that residue. Standard backbone atoms: N, CA, C, O. Common side chain atoms: OG (Ser), NZ (Lys), OD1/OD2 (Asp), NE2 (His). Ligand atom names vary by structure — check the PDB HETATM records.
Measuring H-bond distances automatically
Rather than measuring individual atom pairs manually, distance with mode=2 detects all H-bond donor-acceptor pairs between two selections and draws distance lines for all of them simultaneously:
# All H-bonds between ligand and protein pocket
distance hbonds, LIG, pocket, mode=2
# H-bonds between two chains
distance interface_hbonds, chain A, chain B, mode=2
# H-bonds within a specific region
distance local_hbonds, resi 100-150, resi 100-150, mode=2
# Color H-bond lines yellow (standard publication convention)
color yellow, hbonds
| mode= | What distance detects |
|---|---|
| 0 (default) | All atom pairs within the cutoff — every close contact |
| 1 | Contacts between different residues only |
| 2 | H-bond donor-acceptor pairs (geometric criterion) |
| 3 | Salt bridges (charged atom pairs) |
| 4 | Covalent bond connections |
Angle and dihedral measurements
# Measure bond angle between three atoms (A-B-C)
angle a1, atom_A, atom_B, atom_C
# Example: N-CA-C backbone angle of residue 100
angle phi_100, (resi 100 and name N), (resi 100 and name CA), (resi 100 and name C)
# Dihedral angle between four atoms (A-B-C-D)
dihedral d1, atom_A, atom_B, atom_C, atom_D
# Example: chi1 dihedral of a serine residue
dihedral chi1, (resi 185 and name N), (resi 185 and name CA), \
(resi 185 and name CB), (resi 185 and name OG)
# Hide measurement labels after recording the value
hide labels, a1
hide labels, d1
Measuring across chains
Distances between chains — interface gaps, chain separation, domain movements — use the same commands with chain-specific selections:
# Distance between closest atoms of two chains
distance chain_gap, chain A, chain B
# Distance between specific interface residues across chains
distance iface_contact, resi 73 and chain A, resi 156 and chain B
# All contacts between chain A and chain B within 4 Å
distance contacts, chain A, chain B, 4.0, mode=1
# Distance between Cα atoms of equivalent residues in two structures
distance ca_dist, /structure1//A/GLU`100/CA, /structure2//A/GLU`100/CA
# Center-of-mass distance (via Python)
com_A = cmd.centerofmass("chain A")
com_B = cmd.centerofmass("chain B")
import math
dist = math.sqrt(sum((a-b)**2 for a,b in zip(com_A, com_B)))
print(f"Chain center-of-mass distance: {dist:.2f} Å")
Displaying measurements in publication figures
Measurement objects (distance lines and labels) are rendered during ray tracing and appear in exported figures. Fine-tune their appearance before exporting:
# ── Line style ────────────────────────────────────
set dash_gap, 0.4 # space between dashes (default 0.4)
set dash_length, 0.2 # length of each dash segment
set dash_width, 2.5 # line thickness (default 2.0)
set dash_radius, 0.05 # cylinder radius for 3D dash lines
# ── Label style ───────────────────────────────────
set label_size, 14 # font size in points
set label_color, black # label text color
set label_font_id, 7 # font style (7=sans-serif bold)
set label_position, [0, 0, 1.5] # offset from midpoint
# ── Selective display ─────────────────────────────
show labels, hbonds # show labels for H-bond distances
hide labels, contacts # hide labels — keep lines only
hide dashes, contacts # hide lines but keep labels
# ── Color ─────────────────────────────────────────
color yellow, hbonds # H-bonds: yellow (standard)
color cyan, key_dist # key distances: cyan
color gray60, contacts # background contacts: gray
| Setting | Good value | Effect |
|---|---|---|
| dash_gap | 0.3 – 0.5 | Spacing between dashes — smaller gaps look more solid |
| dash_width | 2.0 – 3.0 | Line thickness — increase for bold publication lines |
| label_size | 12 – 16 | Font size — scale with overall figure resolution |
| label_color | black or white | Black on white backgrounds; white on dark surfaces |
| label_font_id | 7 | Sans-serif bold — most readable in publication figures |
hide labels) and reporting the values in the figure legend instead: “Dashed lines indicate H-bonds; distances are 2.9 Å (Ser185–ligand O3), 3.1 Å (Lys91–ligand N1).” This keeps the 3D figure clean and avoids overlapping label text, while keeping all measurement data in the paper.
Measuring in one paragraph
For quick one-off measurements, use the Wizard (Wizard → Measurement → click atoms). For reproducible, scriptable measurements, use the distance command with named selections — distance hbonds, LIG, pocket, mode=2 finds all H-bonds automatically. Specify exact atoms with resi N and name ATOM and chain X syntax. Style distance objects with dash_width, label_size, and label_color before ray tracing. For clean publication figures, consider hiding labels and reporting distances in the figure legend rather than crowding them onto the structure.