Skip to content

Grid View

Grid view shows a structure from four directions at once, in a 2×2 grid. The four cameras sit on the vertices of a regular tetrahedron around the structure, so the views are spread as evenly as possible (about 109.5° apart) and together cover every side. +Z stays up in every panel. The panels are not labelled; their starting directions are fixed:

from (+1, +1, +1) from (+1, −1, −1)
from (−1, +1, −1) from (−1, −1, +1)

The four panels behave as one rigid body. Dragging in a panel turns the structure in that panel's own screen frame: drag right and it turns right, drag down and it tilts down. All panels follow the same rotation smoothly. Zoom (mouse wheel) is shared by all panels.

Turn it on with the grid button in the toolbar or Layout under View in the sidebar, or from Python or the CLI:

from ase.build import molecule
from aseview import MolecularViewer

viewer = MolecularViewer(molecule("CH3CH2OH"), layout="grid", style="glossy")
viewer.show()

With Other Settings

Grid view only changes where the cameras are. Everything else still applies in every panel: style, Color By (including fragment coloring), opacity, cell, periodic images and polyhedra.

from ase.build import add_adsorbate, fcc111, molecule

slab = fcc111("Pt", size=(3, 3, 3), vacuum=8.0)
add_adsorbate(slab, molecule("CO"), height=1.9, position="ontop")

MolecularViewer(
    slab,
    layout="grid",
    color_by="fragment",               # layers and adsorbate from ASE tags
    fragment_colors={0: "#a855f7"},   # tag 0 = adsorbate
    style="glossy",
).show()

Trajectories

Grid view also works with trajectories. The animation controls play all four panels in sync, so you can follow one motion from every side at once. Below, a CO molecule tilts and lifts off a Pt(111) top site. The layers and the adsorbate are colored from ASE tags.

import numpy as np
from ase.build import add_adsorbate, fcc111, molecule
from aseview import MolecularViewer

base = fcc111("Pt", size=(3, 3, 3), vacuum=8.0)
add_adsorbate(base, molecule("CO"), height=1.9, position="ontop")
carbon, oxygen = len(base) - 2, len(base) - 1
bond = base.get_distance(carbon, oxygen)
anchor = base.positions[carbon].copy()

frames = []
for t in np.linspace(0.0, 1.0, 30):
    atoms = base.copy()
    tilt = np.radians(55.0) * t
    carbon_pos = anchor + np.array([0.9 * t, 0.0, 2.2 * t**2])
    atoms.positions[carbon] = carbon_pos
    atoms.positions[oxygen] = carbon_pos + bond * np.array([np.sin(tilt), 0.0, np.cos(tilt)])
    frames.append(atoms)

MolecularViewer(
    frames,
    layout="grid",
    color_by="fragment",
    fragment_colors={0: "#a855f7"},   # tag 0 = adsorbate
    style="glossy",
).show()

A trajectory file works the same way, for example MolecularViewer("md.traj", layout="grid") or aseview md.traj --grid-view.

Controls and Export

  • The grid button in the toolbar switches between one view and the 2×2 grid.
  • Right-drag (or Shift+drag) pans in the panel under the pointer; the wheel zooms every panel together.
  • PNG and GIF export save the whole 2×2 grid as one image.
  • Orthographic and perspective projection both work. Every panel is framed so the whole structure fits in any orientation.
  • In the fragment selector, rectangle and lasso selection work in whichever panel you drag in.

Command Line

aseview molecule.xyz --grid-view
aseview slab.traj --grid-view --style glossy