Issue with PourbaixPlotter get_pourbaix_plot().show()

I’m testing out pymatgen to see if I can use it for my purposes. The following is my complete code:

from pymatgen.analysis.pourbaix_diagram import PourbaixDiagram, PourbaixPlotter
from pymatgen.ext.matproj import MPRester

# Initialize the MP Rester
mpr = MPRester(MP_API_KEY)

entries = mpr.get_pourbaix_entries(["Al"])

# Construct the PourbaixDiagram object
pbx = PourbaixDiagram(entries)

plotter = PourbaixPlotter(pbx)

plotter.get_pourbaix_plot().show()

Running the code generates the following error:

Exception has occurred: AttributeError
'Axes' object has no attribute 'show'
plotter.get_pourbaix_plot().show()
AttributeError: 'Axes' object has no attribute 'show'

I was wondering if someone could point me to the right direction on how to fix this. Thanks!

Hi Splatfen,

I noticed this recently as well. Previously the pourbaix plotter returned an instance of matplotlib.pyplot but now it returns an axes instance. If you’re in jupyter, try just removing the .show(), i.e. plotter.get_pourbaix_plot(), if you want to use pyplot.show() then you can initialize beforehand and then use show, e.g.

from matplotlib import pyplot as plt
...
plotter.get_pourbaix_plot()
plt.show()