PyMOL Commands Cheat Sheet: The Essential Reference for Structural Biologists
Quick referenceAll levels
Every PyMOL command you’ll reach for regularly — organized by task, not alphabetically. Bookmark this page and keep it open alongside PyMOL while you work.
How to use this reference
All commands are entered in the PyMOL command line at the bottom of the External GUI window. Arguments in [ ] are optional. selection can be any named selection, object name, or selection expression like chain A or resi 100-150.
Loading & fetching
Command
What it does
fetch 4XYZ
Download structure from RCSB PDB and load it
fetch 4XYZ, name
Fetch and assign a custom object name
load protein.pdb
Load a local PDB file
load traj.xtc, protein
Load an MD trajectory into an existing object
load_traj traj.dcd, protein
Alternative trajectory loading (DCD format)
delete all
Remove all loaded objects
delete object_name
Remove a specific object
reinitialize
Reset PyMOL to a completely clean state
Navigation & view
Command
What it does
zoom [selection]
Fit the view to the selection (or everything)
orient [selection]
Orient along principal axes of the selection
center [selection]
Center the view on a selection without zooming
reset
Reset camera to default position
get_view
Print the current view matrix — copy to reproduce later
set_view (matrix)
Restore a previously saved view matrix
turn x, 90
Rotate 90° around the x-axis (also y, z)
rotate x, 45, object
Rotate a specific object by 45° around x
clip near, -5
Adjust near clipping plane
clip far, 5
Adjust far clipping plane
Selections
The backbone of everything in PyMOL. Every command operates on a selection.
Command / syntax
What it does
Creating selections
select name, expression
Create a named selection from an expression
select site, chain A and resi 100-150
Select residues 100–150 of chain A
select pocket, byres (LIG around 5)
Select all residues within 5 Å of LIG
select iface, chain A and (byres chain B around 4)
Interface residues of chain A near chain B
Selection keywords
chain A
All atoms in chain A
resi 100-150
Residue numbers 100 through 150
resi 100+150+273
Specific residue numbers (use + to list)
resn LYS
All lysine residues (3-letter code)
name CA
Alpha carbon atoms only
elem C
All carbon atoms
hetatm
Heteroatoms (ligands, waters, ions)
resn HOH
Water molecules only
b > 70
Atoms with B-factor above 70 (pLDDT for AF)
Boolean operators
chain A and resi 100
Residue 100 in chain A specifically
chain A or chain B
Both chains A and B
not resn HOH
Everything except water
sel1 within 5 of sel2
Atoms in sel1 within 5 Å of sel2
byres (sel around 5)
Complete residues with any atom within 5 Å
Display modes
Command
What it does
show — add a representation
show cartoon [, sel]
Ribbon cartoon for protein backbone
show sticks [, sel]
All bonds as sticks — for residues and ligands
show lines [, sel]
Thin line bonds — lightweight background display
show spheres [, sel]
Space-filling (van der Waals) representation
show surface [, sel]
Molecular surface
show dots [, sel]
Dot surface (accessible surface area)
show mesh [, sel]
Wireframe mesh surface
show nb_spheres [, sel]
Non-bonded atoms as small spheres (ions)
hide — remove a representation
hide everything [, sel]
Remove all representations
hide cartoon [, sel]
Remove cartoon only
hide everything, resn HOH
Remove water molecules from view
as — show only this representation
as cartoon
Cartoon only — hides everything else
as sticks, selection
Sticks only for the selection
as spheres, resn LIG
Space-filling for ligand only
Coloring
Command
What it does
color red [, sel]
Single color — named colors: red, blue, green, white, slate, marine, wheat…
util.cbc [sel]
Color by chain — each chain gets a distinct color
util.cbs [sel]
Color by secondary structure (helix/sheet/loop)
util.cbaw [sel]
Color by atom type — classic CPK scheme, white carbons
util.cbag [sel]
Color by atom type — green carbons (ligand standard)
spectrum b, blue_red
Spectrum by B-factor (pLDDT in AlphaFold structures)
Save full PyMOL session (all objects, views, settings)
load session.pse
Restore a saved session
save output.pdb [, selection]
Export coordinates as PDB (optionally, just a selection)
save output.cif [, selection]
Export as mmCIF format
log_open commands.pml
Start recording all commands to a script file
log_close
Stop recording commands
@script.pml
Run a saved .pml script file
Useful settings
Setting command
Effect
set cartoon_fancy_helices, 1
Rounded ribbon helices — standard for publications
set cartoon_smooth_loops, 1
Smooth loop interpolation
set cartoon_tube_radius, 0.4
Thinner loop tubes (default 0.5)
set stick_radius, 0.15
Thinner sticks (default 0.25) — useful for ligands
set sphere_scale, 0.25
Smaller spheres (useful for ball-and-stick)
set ambient, 0.4
Ambient light level — higher = softer shadows
set specular, 0.3
Shininess — lower = more matte
set light_count, 4
Number of lights — more = smoother shading
set depth_cue, 0
Disable distance fog / depth cueing
set ray_shadow, 1
Enable shadows during ray trace
set antialias, 2
Anti-aliasing level for ray trace (1–4)
Quick workflows
New structure — starting sequence
fetch 4XYZ
as cartoon
hide everything, resn HOH
util.cbc
zoom
AlphaFold pLDDT coloring
load AF-P04637-F1-model_v4.pdb
as cartoon
spectrum b, blue_cyan_yellow_orange_red, minimum=50, maximum=100
bg_color white
Binding site figure
fetch 4XYZ
as cartoon
hide everything, resn HOH
color slate, protein
util.cbag LIG # green carbons for ligand
select site, byres (LIG around 5)
show sticks, site
show surface, site
set transparency, 0.4
zoom site
Publication figure export
bg_color white
set ray_opaque_background, 1
set cartoon_fancy_helices, 1
set ambient, 0.4
set specular, 0.3
ray 1200, 900
png figure1a.png, dpi=300
PyMOL doesn’t auto-save. Before closing, run save session.pse — the PSE file captures everything: loaded structures, selections, colors, measurements, and the current view. Loading the PSE later restores the exact state. Get in the habit of saving PSE files the way you save documents.
The 10 commands you’ll use every day
fetch · as cartoon · hide everything, resn HOH · util.cbc · select · color · show sticks · zoom · get_view · ray + png. Learn these ten cold and every other PyMOL task becomes a variation on a pattern you already know.
PyMOL Scripting for Beginners: Automate Repetitive Tasks with Python 13 min read Beginner to intermediate If you’ve typed the same ten PyMOL commands more than twice, you’re ready to script. PyMOL’s scripting environment is Python — which means every Python skill you already have translates directly. This tutorial takes you from your first saved script…
How to Color AlphaFold Structures by pLDDT in PyMOL: Confidence Visualization Guide 11 min read Beginner to intermediate Every AlphaFold structure comes with per-residue confidence scores encoded directly in the PDB file — but only if you know where to look and how to visualize them. This tutorial covers the complete workflow from loading an…
How to Color Proteins in PyMOL: Every Method Explained 12 min read Beginner to intermediate Coloring is the single most expressive tool in PyMOL — it’s what turns a grey blob into a figure that communicates something specific about structure, function, or confidence. This guide covers every coloring method, when each is appropriate, and the…
How to Visualize Molecular Dynamics Trajectories in PyMOL: Animation, Key Frames and Export 12 min read Intermediate MD trajectories contain the full dynamic story of how a protein moves — but that story is invisible until it’s visualized. This tutorial covers loading trajectories from GROMACS and AMBER into PyMOL, controlling playback, making smooth animations, capturing…
PyMOL Selections: A Complete Guide with Examples 12 min read Beginner to intermediate Selections are the foundation of everything in PyMOL. Every command — coloring, showing, hiding, measuring, labeling — targets a selection. Master the selection syntax and every other PyMOL task becomes straightforward. Contents Anatomy of a selection command Core selection keywords Selecting by…
How to Visualize Protein-Ligand Interactions in PyMOL: Binding Pockets, H-bonds and Publication Figures 13 min read Intermediate Protein-ligand interaction figures are among the most published images in structural biology and drug discovery. This tutorial covers the complete workflow: loading the complex, showing the binding pocket, displaying H-bonds and contacts, measuring key distances, and producing a…