Hi!
I am trying to add an annotation to a ternary, 2D phase diagram defined as:
with MPRester(key) as mpr:
entries = mpr.get_entries_in_chemsys("Nb-Fe-Mn-O")
pd = GrandPotentialPhaseDiagram(entries, chempots=chempot)
fig = PDPlotter(pd).get_plot()
plot_data = PDPlotter(pd).pd_plot_data
lines, stab, unstab = plot_data
and say I’m interested in annotating some text next to an unstable entry. In order to do so, I’d gather the entry coordinates with
for entry, coords in unstab.items():
# logic to select entry
if chemsys == "Mn-Nb-Fe-O": # selecting only phases "inside" the ternary PD
# do as follows
The issue arises when passing coordinates to traces: coords
seems like a tuple of two cartesian coordinates. Passing coords
as in
fig.add_annotation(
x=coords[0],
y=coords[1],
text="my text",
)
doesn’t place the text in the right spot of the ternary diagram.
I suspect a conversion to ternary coordinates would be needed, utilizing the triangular_coord
function as in
tern = triangular_coord(coords)
fig.add_annotation(
x=tern[0],
y=tern[1],
text="my text",
)
but this also misplaces the text.
Seeking decomposition products to calculate manually the ternary coordinates also doesn’t work, as I get ValueError as ValueError: Mn2 Nb8 Fe2 O24 has elements not in the phase diagram Nb, Fe, Mn
.
Is there a way to reliably annotate text on ternary, 2D phase diagrams?
Thank you!