Basic Visualization
Simple Usage
Available Styles
| Style | Description |
|---|---|
cartoon |
Cartoon style with black bonds (default) |
default |
Standard CPK coloring |
neon |
Glowing neon effect |
glossy |
Shiny reflective surface |
metallic |
Metallic appearance |
rowan |
Rowan-inspired style |
bubble |
Bubble-like appearance |
grey |
Greyscale rendering |
Neon Style Example
Partial Charge Visualization
Visualize partial charges using colorBy="Charge". Colors: red (negative) → white (neutral) → blue (positive).
import numpy as np
from ase.io import read
from aseview import MolecularViewer
atoms = read("molecule.xyz")
atoms.arrays['charges'] = np.array([...]) # partial charges
viewer = MolecularViewer(atoms, colorBy="Charge")
viewer.show()
Charge Options
| Option | Description |
|---|---|
colorBy="Charge" |
Enable charge coloring |
normalizeCharges=True |
Scale colors to full range |
showChargeLabels=True |
Display charge values on atoms |
Constraint Visualization
Highlight fixed atoms with showConstraint=True. Fixed atoms from FixAtoms appear with a semi-transparent yellow overlay while keeping their normal element color. The option is only shown when constraints are present.
from ase.constraints import FixAtoms
from aseview import MolecularViewer
atoms.set_constraint(FixAtoms(indices=[0, 1, 2]))
viewer = MolecularViewer(atoms, showConstraint=True)
viewer.show()
See the Solid-State examples for a full surface slab demo.
Customization
viewer = MolecularViewer(
atoms,
style="metallic",
atomSize=0.5, # Atom radius scale
bondThickness=0.15, # Bond radius
bondThreshold=1.2, # Bond detection threshold
backgroundColor="#1a1a2e"
)
viewer.show()
Saving to HTML
Creates a standalone HTML file viewable in any browser without Python.