janosh / pymatviz

A toolkit for visualizations in materials informatics.
https://janosh.github.io/pymatviz
MIT License
156 stars 13 forks source link

Feature: Visualizing Molecules #84

Open JaGeo opened 1 year ago

JaGeo commented 1 year ago

Hi @janosh ,

do you have any plans on supporting visualizations of molecules?

Of course, the following code block arrives at the same purpose but maybe it could be done more naturally?

from pymatgen.core import Molecule
from pymatviz.structure_viz import plot_structure_2d

mol = Molecule(species=["N", "O", "O"],
               coords=[[1.151500, -0.665600, 0.000000], [2.303000, 0.000000, 0.000000], [0.000000, 0.000000, 0.000000]])
plot_structure_2d(mol.get_boxed_structure(15, 15, 15), show_unit_cell=False)

For a porphyrine, it does look quite nice (except that my mol file does not seem to have H atoms): image

janosh commented 1 year ago

In principle, I'd like to have feature parity for molecules and structures. In practice though, it's not on the immediate roadmap due to lack of time. Any contributions would be much appreciated, of course! 🙏

In the long run, I'd like to write a Jupyter integration for the elementari interactive structure viewer which itself is far from finished.

On that note, @ixxie has kindly offered to contribute his Molecule viewer to elementari (see https://github.com/threlte/threlte/issues/360). You can see a live demo of his component at https://rapc.science. Looks really nice! And should speed up the timeline for getting better molecule visualization into pymatviz.