Visualising crystal structures with fresnel and matplotlibΒΆ

This example takes some crystal structures and visualises them with fresnel and matplotlib. It requires fresnel to be installed from conda-forge with conda install fresnel -c conda-forge.

from matador.utils.viz_utils import fresnel_plot
from matador.utils.optimade_utils import optimade2dict
import requests
crystals = [
    optimade2dict(structure) for structure in
import matplotlib.pyplot as plt
fig, axes, scenes = fresnel_plot(crystals, fig_rows=2, figsize=(8, 8))

Optional: install PySide2 to use interactive scene views with fresnel. Useful for finding the desired camera angle for a given structure.

from PySide2 import QtCore
%gui qt
import fresnel.interact
view = fresnel.interact.SceneView(scenes[5])
# Move camera to desired position and observe changes
', 6.2127504, 6.2127504), look_at=(2.4425, 2.4425, 2.4425), up=(-0.4082483, 0.8164966, -0.4082483), height=11.753877639770508)'
from matador.utils.viz_utils import rerender_scenes_to_axes
rerender_scenes_to_axes(scenes, axes)