Package: widget-bandsplot
widget-bandsplot: Jupyter Widget to Plot Band Structure and Density of StatesA Jupyter widget to plot band structures and density of states. The widget is using thebands-widgetJavascript package,
which is developed by Materials Cloud group.InstallationTo install use pip:$ pip install widget_bandsplotUsage1. Plot both the band structure and the density of states (DOS) side by sidew=BandsPlotWidget(bands=[banddata1,banddata2],dos=dosdata,plot_fermilevel=True,show_legend=True,energy_range={"ymin":-10.0,"ymax":10.0})display(w)In order to plot the band structure and density of states, one needs
to provide bands data and DOS data as JSON-files. The examples of the input
JSON-files are provided in theexamples/datafolder. The JSON-files for the
band structure can be exported with theAiiDA command line interface (CLI)verdias demonstrated in
the code below:verdidatabandexport<PK>--format=jsonOne can plot several band structure input files together with the widget.
The format of the DOS input dict is validate by thePDOS Schema, the exampla valid input is:dos_data={"fermi_energy":-7.0,"dos":[{"label":"Total DOS",# required"x":[0.0,0.1,0.2],# required"y":[1.2,3.2,0.0],# required"borderColor":"#41e2b3",# optional"backgroundColor":"#51258b",# optional"backgroundAlpha":"52%",#optional: A string with integer between 0-100 and '%' in end."lineStyle":"dash",# optional},{"label":"Co (s↑)","x":[0.0,0.1,0.2],"y":[1.2,3.2,0.0],"lineStyle":"solid","borderColor":"#43ee8b","backgroundColor":"#59595c",},{"label":"Co (s↓)","x":[0.0,0.1,0.2],"y":[1.2,3.2,0.0],"lineStyle":"solid","borderColor":"#403bae","backgroundColor":"#a16c5e",},],}2. Plot only the band structurew=BandsPlotWidget(bands=[banddata1,banddata2],plot_fermilevel=True,show_legend=True,energy_range={"ymin":-10.0,"ymax":10.0})display(w)3. Plot only the density of states (DOS)w=BandsPlotWidget(dos=dosdata,plot_fermilevel=True,show_legend=True,energy_range={"ymin":-10.0,"ymax":10.0})display(w)When only plotting the density of states, the plot will be shown in
horizontal format.For developersFor a development installation (requiresNode.jsandYarn version 1),$ git clone https://github.com/osscar/widget-bandsplot.git
$ cd widget-bandsplot
$ pip install -e .
$ jupyter nbextension install --py --symlink --overwrite --sys-prefix widget_bandsplot
$ jupyter nbextension enable --py --sys-prefix widget_bandsplotWhen actively developing your extension for JupyterLab, run the command:$ jupyter labextension develop --overwrite widget_bandsplotThen you need to rebuild the JS when you make a code change:$ cd js
$ yarn run buildYou then need to refresh the JupyterLab page when your javascript changes.For maintainersTo create a new release, clone the repository, install development dependencies withpip install -e '.[dev]', and then executebumpver update [--major|--minor|--patch] [--tag [alpha|beta|rc]].
This will:Create a tagged release with bumped version and push it to the repository.Trigger a GitHub actions workflow that creates a GitHub release and publishes it on PyPI.Additional notes:Use the--dryoption to preview the release change.The release tag (e.g. a/b/rc) is determined from the last release.
Use the--tagoption to switch the release tag.This packages follows semantic versioning.AcknowledgementsWe acknowledge support from the EPFL Open Science Fund via theOSSCARproject.