Visualization with plato#

In this notebook, we run a Lennard-Jones simulation, color particles according to their local density computed with freud, and display the results with plato. Note that plato has multiple backends – see the plato documentation for information about each backend and the features it supports.

import hoomd


# Silence the HOOMD output

# Create a 10x10x10 simple cubic lattice of particles with type name A
system = hoomd.init.create_lattice(, type_name="A"), n=10

# Specify Lennard-Jones interactions between particle pairs
nl =
lj =, nlist=nl)
lj.pair_coeff.set("A", "A", epsilon=1.0, sigma=1.0)

# Integrate at constant temperature
integrator =, kT=0.01, tau=0.5)

# Run for 10,000 time steps
snap = system.take_snapshot()
HOOMD-blue v2.6.0-151-gea140cffb DOUBLE HPMC_MIXED MPI TBB SSE SSE2 SSE3 SSE4_1 SSE4_2 AVX AVX2
Compiled: 09/25/2019
Copyright (c) 2009-2019 The Regents of the University of Michigan.
You are using HOOMD-blue. Please cite the following:
* J A Anderson, C D Lorenz, and A Travesset. "General purpose molecular dynamics
  simulations fully implemented on graphics processing units", Journal of
  Computational Physics 227 (2008) 5342--5359
* J Glaser, T D Nguyen, J A Anderson, P Liu, F Spiga, J A Millan, D C Morse, and
  S C Glotzer. "Strong scaling of general-purpose molecular dynamics simulations
  on GPUs", Computer Physics Communications 192 (2015) 97--107
HOOMD-blue is running on the CPU

Now we import the modules needed for visualization.

import freud
import numpy as np
import plato

# For interactive scenes, use:
import plato.draw.pythreejs as draw
from matplotlib.colors import Normalize

# For static scenes, use:
# import plato.draw.fresnel as draw

This code sets up the plato Scene object with the particles and colors computed above.

positions = snap.particles.position
box = freud.Box.from_box(
ld = freud.density.LocalDensity(3.0, 1.0)
colors =
radii = np.ones(len(positions)) * 0.5
box_prim = draw.Box.from_box(box, width=0.2)
sphere_prim = draw.Spheres(
    positions=snap.particles.position, radii=radii, colors=colors, vertex_count=32
scene = draw.Scene((sphere_prim, box_prim), zoom=1.5)

Click and drag the 3D scene below - it’s interactive!