Python / Jupyter Quickstart

Load and render

from xyzrender import load, render

mol = load("caffeine.xyz")
render(mol, output="caffeine.svg")

Results display inline in Jupyter automatically — render() returns an SVGResult object with a rich HTML repr.

# Inline display in notebook — no output= needed
render(mol)

Pass render options as keyword arguments:

render(mol, output="caffeine.png", hy=True, config="paton")

Orient interactively

orient() opens the molecule in the v viewer for interactive rotation. Rotate to the desired view, press z, then q. The rotated positions are written back to mol and mol.oriented is set to True so subsequent render() calls skip auto-orientation.

from xyzrender import orient

orient(mol)
render(mol, output="oriented.svg")

Save geometry

Write the current atom positions back to an XYZ file with mol.to_xyz(). For crystal structures the output is extXYZ format with a Lattice= header:

mol.to_xyz("output.xyz")
mol.to_xyz("output.xyz", title="My molecule")

GIF animations

from xyzrender import render_gif

render_gif(mol, gif_rot="y", output="caffeine.gif")
render_gif(mol, gif_diffuse=True, output="diffuse.gif")

See Core API for the full API reference.