def pdos_from_files(return_plt=False, **kwargs): """Read input data, process for PDOS before plotting and/or writing Args: return_plt (bool): If True, return the pyplot object instead of writing or displaying plot output. **kwargs: See command reference for full argument list """ pdos_plotting_data = galore.process_pdos(**kwargs) # For plotting and writing, "None" means "write to screen" # while False means "do nothing" if kwargs['plot'] or kwargs['plot'] is None: if 'style' in kwargs and kwargs['style'] is not None: import matplotlib.pyplot matplotlib.pyplot.style.use(kwargs['style']) plt = galore.plot.plot_pdos(pdos_plotting_data, **kwargs) # flipx is included in kwargs if kwargs['overlay'] is not None: plt = galore.plot.add_overlay( plt, kwargs['overlay'], overlay_offset=kwargs['overlay_offset'], overlay_scale=kwargs['overlay_scale'], overlay_style=kwargs['overlay_style'], overlay_label=kwargs['overlay_label']) plt.legend(loc='best') xlabel = galore.plot.guess_xlabel(units=kwargs['units'], flipx=kwargs['flipx'], energy_label=None) plt.xlabel(xlabel) if kwargs['ylabel'] is not None: plt.ylabel(kwargs['ylabel']) if return_plt: return plt elif kwargs['plot']: plt.savefig(kwargs['plot']) elif kwargs['plot'] is None: plt.show() if kwargs['csv'] or kwargs['csv'] is None: galore.formats.write_pdos(pdos_plotting_data, filename=kwargs['csv'], filetype='csv', flipx=kwargs['flipx']) if kwargs['txt'] or kwargs['txt'] is None: galore.formats.write_pdos(pdos_plotting_data, filename=kwargs['txt'], filetype='txt', flipx=kwargs['flipx'])
import galore import galore.plot vasprun = 'test/SnO2/vasprun.xml.gz' xmin, xmax = (-10, 4) fig = plt.figure() ax = fig.add_subplot(1, 1, 1) weightings = ('He2', 'Alka', 'Yeh_HAXPES') for i, weighting in enumerate(weightings): plotting_data = galore.process_pdos(input=[vasprun], gaussian=0.3, lorentzian=0.2, xmin=xmin, xmax=xmax, weighting=weighting) galore.plot.plot_pdos(plotting_data, ax=ax, show_orbitals=False, units='eV', xmin=-xmin, xmax=-xmax, flipx=True) line = ax.lines[-1] line.set_label(weighting) line.set_color(cmap(i / len(weightings))) ymax = max(line.get_ydata())
#! /usr/bin/env python3 import numpy as np import matplotlib.pyplot as plt import galore import galore.plot vasprun = './test/MgO/vasprun.xml.gz' xmin, xmax = (-10, 2) fig = plt.figure() for i, l in enumerate(np.arange(0.05, 0.50, 0.05)): ax = fig.add_subplot(3, 3, i + 1) ax.set_title("$\gamma = {0:4.2f}$".format(l)) plotting_data = galore.process_pdos(input=[vasprun], lorentzian=l, xmin=xmin, xmax=xmax) galore.plot.plot_pdos(plotting_data, ax=ax) ax.legend().set_visible(False) fig.tight_layout() plt.show()
ax3.set_xlim(xlim) ax3.legend().remove() ## Fix consistent colors for line in ax3.lines: line.set_color(line_colors[line.get_label()]) line.set_linestyle('-') # Summed PDOS ax4 = fig.add_subplot(1, 5, 4, sharey=ax3) galore.plot.plot_pdos(weighted_data, ax=ax4, total=True, show_orbitals=False) ax4.set_title("Sum") ax4.set_xlim(xlim) ax4.set_ylim(new_ylim) ax4.legend().remove() # Broadened output ax5 = fig.add_subplot(1, 5, 5) broadened_data = galore.process_pdos(input='test/MgO/vasprun.xml.gz', gaussian=0.5, weighting=weighting) galore.plot.plot_pdos(broadened_data, ax=ax5, total=True, show_orbitals=False) ax5.set_title("Broaden") ax5.set_xlim(xlim) ax5.set_ylim(final_ylim) ax5.legend().remove() fig.subplots_adjust(left=0.03, right=0.98, top=0.78) fig.savefig('docs/source/figures/pe_schematic.pdf')