-
Notifications
You must be signed in to change notification settings - Fork 921
Description
Python version
Python 3.11.11
Pymatgen version
2025.4.17
Operating system version
Mac OS X 15.3.2
Current behavior
When plotting 2D ternary (and 3D quaternary) phase diagrams with PDPlotter
, if there are multiple above-hull entries for a non-hull composition, the plot will typically show the higher-energy entry (not sure if this always true or just sometimes true) . This leads to the perception that these compositions are further above the hull then they probably should be.
I believe this is an oversight in the plotly marker code (which I wrote a few years back).
Expected Behavior
If you only take the minimum-energy entries for every composition, you see a more realistic representation of the above-hull compositions.
The differences are subtle in this particular system, but check out Li5Fe5O12, for example. This kind of misleading plotting is worse in larger materials databases.
Minimal example
with MPRester() as mpr:
ents = mpr.get_entries_in_chemsys("Li-Fe-O")
min_entries = {}
for ent in ents:
if ent.composition.reduced_formula in min_entries:
if ent.energy_per_atom < min_entries[ent.composition.reduced_formula].energy_per_atom:
min_entries[ent.composition.reduced_formula] = ent
else:
min_entries[ent.composition.reduced_formula] = ent
pd1 = PhaseDiagram(ents).get_plot()
pd2 = PhaseDiagram(min_entries.values()).get_plot()
Relevant files to reproduce this bug
No response