.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_phbands_grid.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plot_phbands_grid.py: Multiple phonon bands ===================== This example shows how to plot several phonon band structures on a grid. We use two files produced by anaddb: 1) trf2_5.out_PHBST.nc: phonon frequencies on a q-path in the BZ (used to plot the band dispersion) 2) trf2_5.out_PHDOS.nc: phonon DOS compute with anaddb. See also tutorial/lesson_rf2.html .. GENERATED FROM PYTHON SOURCE LINES 19-22 We start by defining a list with the paths to the PHBST.nc files In this case, for simplicity, we use the same file but we must use different labels when adding them to the plotter with the add_phbands method. .. GENERATED FROM PYTHON SOURCE LINES 22-32 .. code-block:: Python from abipy import abilab import abipy.data as abidata phbst_paths = 2 * [abidata.ref_file("trf2_5.out_PHBST.nc")] plotter = abilab.PhononBandsPlotter() plotter.add_phbands("AlAs", phbst_paths[0]) plotter.add_phbands("Same AlAs", phbst_paths[1]) .. rst-class:: sphx-glr-script-out .. code-block:: none Warning: file /home/runner/work/abipy/abipy/abipy/data/refs/alas_phonons/trf2_5.out_PHBST.nc does not contain atomic_numbers. Particular methods need them! Warning: file /home/runner/work/abipy/abipy/abipy/data/refs/alas_phonons/trf2_5.out_PHBST.nc does not contain atomic_numbers. Particular methods need them! .. GENERATED FROM PYTHON SOURCE LINES 33-35 At this point, we can use the plotter methods to plot the data: To produce a grid plot: .. GENERATED FROM PYTHON SOURCE LINES 35-38 .. code-block:: Python plotter.gridplot(units="eV", title="GridPlot in eV") .. image-sg:: /gallery/images/sphx_glr_plot_phbands_grid_001.png :alt: GridPlot in eV, AlAs, Same AlAs :srcset: /gallery/images/sphx_glr_plot_phbands_grid_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 39-40 For the plotly version, use: .. GENERATED FROM PYTHON SOURCE LINES 40-43 .. code-block:: Python plotter.gridplotly(units="eV", title="GridPlotly in eV") .. GENERATED FROM PYTHON SOURCE LINES 44-45 To produce a box plot with matplotly, use: .. GENERATED FROM PYTHON SOURCE LINES 45-53 .. code-block:: Python plotter.boxplot(units="cm-1", title="BoxPlot in cm-1") plotter.combiboxplot(units="Ha", title="CombiboxPlot in Ha") #plotter.boxplotly(units="eV", title="GridPlot in eV") #plotter.combiplot(title="CombiPlot in eV") .. rst-class:: sphx-glr-horizontal * .. image-sg:: /gallery/images/sphx_glr_plot_phbands_grid_002.png :alt: BoxPlot in cm-1, AlAs, Same AlAs :srcset: /gallery/images/sphx_glr_plot_phbands_grid_002.png :class: sphx-glr-multi-img * .. image-sg:: /gallery/images/sphx_glr_plot_phbands_grid_003.png :alt: CombiboxPlot in Ha :srcset: /gallery/images/sphx_glr_plot_phbands_grid_003.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 54-58 To plot a grid with band structures + DOS, use the optional argument `phdos` of add_phbands The first subplot gets the band dispersion from phbst_paths[0] and the dos from phdos_paths[0] .. GENERATED FROM PYTHON SOURCE LINES 58-67 .. code-block:: Python phbst_paths = 3 * [abidata.ref_file("trf2_5.out_PHBST.nc")] phdos_paths = 3 * [abidata.ref_file("trf2_5.out_PHDOS.nc")] plotter = abilab.PhononBandsPlotter() plotter.add_phbands("AlAs phbands + DOS", phbst_paths[0], phdos=phdos_paths[0]) plotter.add_phbands("Same-data", phbst_paths[1], phdos=phdos_paths[1]) plotter.add_phbands("Same-data2", phbst_paths[2], phdos=phdos_paths[2]) .. rst-class:: sphx-glr-script-out .. code-block:: none Warning: file /home/runner/work/abipy/abipy/abipy/data/refs/alas_phonons/trf2_5.out_PHBST.nc does not contain atomic_numbers. Particular methods need them! Warning: file /home/runner/work/abipy/abipy/abipy/data/refs/alas_phonons/trf2_5.out_PHBST.nc does not contain atomic_numbers. Particular methods need them! Warning: file /home/runner/work/abipy/abipy/abipy/data/refs/alas_phonons/trf2_5.out_PHBST.nc does not contain atomic_numbers. Particular methods need them! .. GENERATED FROM PYTHON SOURCE LINES 68-69 To visualize the results on a grid with matplotlib, use: .. GENERATED FROM PYTHON SOURCE LINES 69-74 .. code-block:: Python plotter.gridplot(units="cm-1", tight_layout=True, title="Bands + DOS in cm-1 with gridplot") #plotter.combiplot(title="Bands + DOS in eV with combiplot") .. image-sg:: /gallery/images/sphx_glr_plot_phbands_grid_004.png :alt: Bands + DOS in cm-1 with gridplot, AlAs phbands + DOS, Same-data, Same-data2 :srcset: /gallery/images/sphx_glr_plot_phbands_grid_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 75-76 For the plotly version: .. GENERATED FROM PYTHON SOURCE LINES 76-78 .. code-block:: Python plotter.gridplotly(units="cm-1", title="Bands + DOS in cm-1 with gridplot") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.356 seconds) .. _sphx_glr_download_gallery_plot_phbands_grid.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_phbands_grid.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_phbands_grid.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_phbands_grid.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_