janosh / pymatviz

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

Add `coordination_vs_cutoff_line` plot function #236

Closed janosh closed 1 month ago

janosh commented 1 month ago
import pymatviz as pmv

from pymatgen.core import Lattice, Structure

struct = Structure(
    lattice=Lattice.cubic(3),
    species=("Fe", "O"),
    coords=((0, 0, 0), (0.5, 0.5, 0.5)),
)

custom_colors = {"Fe": "red", "O": "blue"}
fig = pmv.coordination_vs_cutoff_line(
    struct, element_color_scheme=custom_colors
)

coordination-vs-cutoff-custom-colors

multi structure example

fig = pmv.coordination_vs_cutoff_line(
    {key1: structures[key1], key2: structures[key2], key3: structures[key3]},
    strategy=(1.0, 6.0),
    num_points=100,
)
fig.layout.title = dict(
    text="Coordination vs Cutoff: Multiple Structures", x=0.5, y=0.98
)
fig.layout.legend.update(x=0, y=1, bgcolor="rgba(0,0,0,0)")
fig.layout.margin.t = 50
fig.show()

coordination-vs-cutoff-multiple