A example of phase diagram at new mp_api website

I am a new user of mp_api. When I ran a example code at new mp_api website to generate a phase diagram, the following Error messages appeared, and No phase diagram was generated, why?

from mp_api.client import MPRester
from pymatgen.analysis.phase_diagram import PhaseDiagram, PDPlotter

with MPRester("API_KEY_HERE") as mpr:
    entries = mpr.get_entries_in_chemsys(elements=["Li", "Fe", "O"],
                                         additional_criteria={"thermo_types": ["GGA_GGA+U"]})
    pd = PhaseDiagram(entries)
    PDPlotter(pd).get_plot().show()

This isn’t an error, it’s just a warning, so the code is running and completing. The problem is that you’re not saving the phase diagram anywhere or showing it:

Change the last line to:

PDPlotter(pd).get_plot().show()

Also, your API key is meant to be kept secret - please don’t post it to the forum. I’ve edited your post to remove the API key but have a text version of the example script.

Hi, Mr.Montoya! Thanks a lot! I try to your code and get a phase diagram successfully. And thank you for removing my API key.

1 Like