Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor interface_reactions module, add support for Plotly #2233

Merged
merged 9 commits into from
Sep 8, 2021
5 changes: 3 additions & 2 deletions pymatgen/analysis/chempot_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
from plotly.graph_objects import Scatter, Scatter3d, Mesh3d, Figure
from scipy.spatial import ConvexHull, HalfspaceIntersection

from pymatgen.analysis.phase_diagram import PDPlotter, PhaseDiagram, PDEntry
from pymatgen.analysis.phase_diagram import PhaseDiagram, PDEntry
from pymatgen.core.composition import Composition, Element
from pymatgen.entries.computed_entries import ComputedEntry
from pymatgen.util.coord import Simplex
from pymatgen.util.string import htmlify

with open(os.path.join(os.path.dirname(__file__), "..", "util", "plotly_chempot_layouts.json")) as f:
plotly_layouts = json.load(f)
Expand Down Expand Up @@ -473,7 +474,7 @@ def _get_min_entries_and_el_refs(
@staticmethod
def _get_annotation(ann_loc: np.ndarray, formula: str) -> Dict[str, Union[str, float]]:
"""Returns a Plotly annotation dict given a formula and location"""
formula = PDPlotter._htmlize_formula(formula)
formula = htmlify(formula)
annotation = plotly_layouts["default_annotation_layout"].copy()
annotation.update({"x": ann_loc[0], "y": ann_loc[1], "text": formula})
if len(ann_loc) == 3:
Expand Down