crystal_toolkit.core.legend module — Crystal Toolkit documentation

# crystal_toolkit.core.legend module

class crystal_toolkit.core.legend.Legend(site_collection: SiteCollection | Site, color_scheme: str = 'Jmol', radius_scheme: str = 'uniform', cmap: str = 'coolwarm', cmap_range: tuple[float, float] | None = None)

  Bases: `MSONable`

  Help generate a legend (colors and radii) for a Structure or Molecule such that colors and radii can be displayed for the appropriate species.

  Note that species themselves have a color (for example, Oxygen is typically red), but that we might also want to color-code by site properties (for example, magnetic moment), thus this class has to take into account both the species present and its context (the specific site the species is at) to correctly generate the legend.

  static analyze_site_props(site_collection: SiteCollection) → dict[str, list[str]]

    Returns: A dictionary with keys “scalar”, “matrix”, “vector”, “categorical” and values of a list of site property names corresponding to each type

  default_color = [0, 0, 0]
  default_color_scheme = 'Jmol'
  default_radius = 1.0
  fallback_radius = 0.5
  static generate_accessible_color_scheme_on_the_fly(site_collection: SiteCollection) → dict[str, dict[str, tuple[int, int, int]]]

    e.g. for a color scheme more appropriate for people with color blindness

    Parameters

      site_collection – SiteCollection

    Returns: A dictionary in similar format to EL_COLORS

  static generate_categorical_color_scheme_on_the_fly(site_collection: SiteCollection, site_prop_types) → dict[str, dict[str, tuple[int, int, int]]]

    e.g. for Wykcoff

    Parameters

      site_collection – SiteCollection

    Returns: A dictionary in similar format to EL_COLORS

  get_color(sp: Specie | Element, site: Site | None = None) → str

    Get a color to render a specific species. Optionally, you can provide a site for context, since …

    Parameters

      - sp – Specie or Element

      - site – Site

    Returns: Color

  get_legend() → dict[str, Any]
  get_radius(sp: Specie | Element, site: Site | None = None) → float
  static get_species_str(sp: Specie | Element) → str
    Parameters

      sp – Specie or Element

    Returns: string representation

  uniform_radius = 0.5