erlab.plotting.atoms

Plot atoms.

Classes and functions for plotting atoms and bonds in a crystal structure using matplotlib’s 3D plotting capabilities.

Some of the projection code was adapted from kwant.

Classes

CrystalProperty(atom_pos, avec[, offset, ...])

class erlab.plotting.atoms.CrystalProperty(atom_pos, avec, offset=(0.0, 0.0, 0.0), radii=None, colors=None, repeat=(1, 1, 1), bounds=None, mask=None, r_factor=0.4)[source]

Bases: object

classmethod from_fractional(frac_pos, avec, *args, **kwargs)[source]
property bounds: list[tuple[float, float]]
property atoms: list[str]
property atom_pos: dict[str, ndarray[tuple[Any, ...], dtype[float64]]]
clear_bonds()[source]
add_bonds(atom1, atom2, min_length=0.0, max_length=2.6, linewidth=0.25, color=None)[source]
plot(ax=None, scale_bonds=True, scale_atoms=True, clean_axes=True, bond_kw=None, atom_kw=None)[source]

Plot the crystal structure.

Parameters:
  • ax (Axes3D | None, default: None) – A 3D axes object to plot the crystal on. If not provided, add_subplot will be called on the current figure.

  • scale_bonds (bool, default: True) – Whether to scale the bond linewidths based on the distance from the camera, by default True

  • scale_atoms (bool, default: True) – Whether to scale the atom sizes based on the distance from the camera, by default True

  • clean_axes (bool, default: True) – Whether to clean the axes by removing the background and grid, setting pane color, and removing the margins, by default True

  • bond_kw (dict | None, default: None) – Keyword arguments passed onto Bond3DCollection

  • atom_kw (dict | None, default: None) – Keyword arguments passed onto mpl_toolkits.mplot3d.Axes3D.scatter used to plot the atoms.