2323
2424from pymatgen .io .vasp .outputs import BSVasprun
2525from pymatgen .electronic_structure .bandstructure import get_reconstructed_band_structure
26- from pymatgen .electronic_structure .plotter import BSPlotter
26+ from pymatgen .electronic_structure .plotter import plot_brillouin_zone
2727import matplotlib as mpl
28-
2928mpl .use ("Agg" )
29+ from sumo .plotting import pretty_plot_3d
30+
3031__author__ = "Arthur Youd"
3132__version__ = "1.0"
3233__maintainer__ = "Alex Ganose"
3536
3637
3738def brillplot (filenames = None , prefix = None , directory = None ,
39+ width = 6 , height = 6 , fonts = None ,
3840 image_format = "pdf" , dpi = 400 ):
3941 """Generate plot of first brillouin zone from a band-structure calculation.
4042 Args:
@@ -57,17 +59,28 @@ def brillplot(filenames=None, prefix=None, directory=None,
5759 bs = vr .get_band_structure (line_mode = True )
5860 bandstructures .append (bs )
5961 bs = get_reconstructed_band_structure (bandstructures )
60- plotter = BSPlotter (bs )
61- plt = plotter .plot_brillouin ()
62+
63+ labels = {}
64+ for k in bs .kpoints :
65+ if k .label :
66+ labels [k .label ] = k .frac_coords
67+
68+ lines = []
69+ for b in bs .branches :
70+ lines .append ([bs .kpoints [b ['start_index' ]].frac_coords ,
71+ bs .kpoints [b ['end_index' ]].frac_coords ])
72+
73+ plt = pretty_plot_3d (width , height , dpi = dpi , fonts = fonts )
74+ fig = plot_brillouin_zone (bs .lattice_rec , lines = lines , labels = labels ,
75+ ax = plt .gca ())
6276
6377 basename = "brillouin.{}" .format (image_format )
6478 filename = "{}_{}" .format (prefix , basename ) if prefix else basename
6579 if directory :
6680 filename = os .path .join (directory , filename )
67- plt .savefig (filename , format = image_format , dpi = dpi , bbox_inches = "tight" )
81+ fig .savefig (filename , format = image_format , dpi = dpi , bbox_inches = "tight" )
6882 return plt
6983
70-
7184def find_vasprun_files ():
7285 """Search for vasprun files from the current directory.
7386
@@ -99,7 +112,7 @@ def find_vasprun_files():
99112
100113def _get_parser ():
101114 parser = argparse .ArgumentParser (description = """
102- brillplot is a script to produce publication-ready
115+ brillplot is a script to produce publication-ready
103116 brillouin zone diagrams""" ,
104117 epilog = """
105118 Author: {}
0 commit comments