Skip to content

Commit

Permalink
Add support for titles
Browse files Browse the repository at this point in the history
  • Loading branch information
oashour committed Jul 7, 2023
1 parent 0f469ef commit 11ec551
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sumo/cli/bandplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def bandplot(
dpi=400,
plt=None,
fonts=None,
title=None,
):
"""Plot electronic band structure diagrams from vasprun.xml files.
Expand Down Expand Up @@ -439,6 +440,7 @@ def bandplot(
style=style,
no_base_style=no_base_style,
spin=spin,
title=title,
)
else:
plt = plotter.get_plot(
Expand All @@ -459,6 +461,7 @@ def bandplot(
style=style,
no_base_style=no_base_style,
spin=spin,
title=title,
)

if save_files:
Expand Down Expand Up @@ -849,6 +852,7 @@ def _get_parser():
"--dpi", type=int, default=400, help="pixel density for image file"
)
parser.add_argument("--font", default=None, help="font to use")
parser.add_argument("--title", default=None, help="plot title")
return parser


Expand Down Expand Up @@ -918,6 +922,7 @@ def main():
image_format=args.image_format,
dpi=args.dpi,
fonts=args.font,
title=args.title,
)


Expand Down
8 changes: 8 additions & 0 deletions sumo/plotting/bs_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def get_plot(
fonts=None,
style=None,
no_base_style=False,
title=None,
):
"""Get a :obj:`matplotlib.pyplot` object of the band structure.
Expand Down Expand Up @@ -315,6 +316,7 @@ def get_plot(
dos_label=dos_label,
aspect=aspect,
spin=spin,
title=title,
)
return plt

Expand Down Expand Up @@ -352,6 +354,7 @@ def get_projected_plot(
style=None,
no_base_style=False,
spin=None,
title=None,
):
"""Get a :obj:`matplotlib.pyplot` of the projected band structure.
Expand Down Expand Up @@ -686,6 +689,7 @@ def get_projected_plot(
plot_dos_legend=plot_dos_legend,
aspect=aspect,
spin=spin,
title=title,
)
return plt

Expand All @@ -707,6 +711,7 @@ def _makeplot(
plot_dos_legend=True,
aspect=None,
spin=None,
title=None,
):
"""Tidy the band structure & add the density of states if required."""
if zero_line:
Expand All @@ -730,6 +735,9 @@ def _makeplot(
for vbm in data["vbm"]:
ax.scatter(vbm[0], vbm[1], color="C3", marker="o")

if title:
fig.suptitle(title)

if dos_plotter:
ax = fig.axes[1]

Expand Down
1 change: 1 addition & 0 deletions sumo/plotting/sumo_base.mplstyle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
figure.figsize : 3.2, 3.2
figure.dpi: 400
figure.titlesize: 14

axes.prop_cycle: cycler('color', ['f0a3ff', '0075dc', '993f00', '4c005c', '426600', 'ff0010', '9dcc00', 'c20088', '003380', 'ffa405', 'ffff00', 'ff5005', '5ef1f2', '740aff', '990000', '00998f', '005c31', '2bce48', 'ffcc99', '94ffb5', '8f7c00', '6fa8bb', '808080'])

Expand Down

3 comments on commit 11ec551

@SpinTherm
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am new to GitHub, I do not know if this is proper place for this comment. Apologies if this isn't. Thanks for this very useful code. How can I make legends (for example, spin up and spin down) to show up in single band structure plot?

@oashour
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to GitHub; a more proper place would be opening a new issue :). Spin up/down legends are currently unavailable in the main branch of sumo, but I did implement it a while back in my compare branch https://github.com/oashour/sumo/tree/compare (specifically this commit oashour@63e8dbd). I haven't had the time to clean it up and open a PR to add this to the main branch, maybe soon...

You could pull my fork, check out the compare branch, and install it in your virtual env instead of standard sumo. But of course, you'll be using a development version that hasn't even been updated from upstream in a while.

@SpinTherm
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for the reply and information.

Please sign in to comment.