BSPlotterProjected.get_elt_projecte_plots() method broken

I have calculated the band structure for the 2D material MoSe2. I can plot the band structure without problem using the BSDosPlotter, but when I tried to use the BSPlotterProjected, a broken plot with only one of the elements (Se) is returned. I have attached the code to generate the plot below as well as the graphics (in PDF form) that are produced. Am I doing something incorrectly or is the code broken?

Python 3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:34:09) [GCC 12.3.0]

Type ‘copyright’, ‘credits’ or ‘license’ for more information

IPython 8.15.0 – An enhanced Interactive Python. Type ‘?’ for help.

In [1]: bsrun = Vasprun(“vasprun.xml”,parse_projected_eigen=True)

In [2]: bs = bsrun.get_band_structure(line_mode=True)

In [3]: from pymatgen.electronic_structure.plotter import BSPlotterProjected

In [4]: plotter = BSPlotterProjected(bs)

In [5]: plot = plotter.get_elt_projected_plots()

Installed qt5 event loop hook.

In [6]: figure = plot.get_figure()

brokenplot.pdf (1.6 MB)


Thanks for reporting this. Do you mind sharing the vasprun.xml?
Also, is your pymatgen recent?

Certainly, here is the vasprun.xml file. This was created running Vasp 6.4.2 and pymatgen 2023.10.11. The uncompressed version of the vasprun.xml file is quite large so here is a bzip2 compressed version. This gives the same result for the plot.
vasprun.xml.bz2 (1.7 MB)


I’m a little late here.
I confirm that function is broken. To make it work you need to replace:
plt.subplot(220 + count)
ax = plt.subplot(220 + count)

It is not a polished function over all: it will produce always 4 plots indipendently of the number of elements, for example.

I suggest you to have a look at the other two functions:

I’ll submit an issue into pymatgen, or you can do it if you like.
In case, please, cite this discussion.

Hope this helps

FYI, this bug has been fixed in pmg.