How to use the abipy.tools.plotting.add_fig_kwargs function in abipy

To help you get started, we’ve selected a few abipy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github abinit / abipy / abipy / eph / sigeph.py View on Github external
    @add_fig_kwargs
    def plot_a2fw_all(self, units="meV", what="auto", sharey=False, fontsize=8, **kwargs):
        """
        Plot the Eliashberg function a2F_{n,k,spin}(w) (gkq2/Fan-Migdal/DW/Total contribution)
        for all k-points, spin and the VBM/CBM for these k-points.

        Args:
            units: Units for phonon plots. Possible values in ("eV", "meV", "Ha", "cm-1", "Thz").
                Case-insensitive.
	    what: fandw for FAN, DW. gkq2 for $|gkq|^2$. Auto for automatic selection based on imag_only
            sharey: True if Y axes should be shared.
            fontsize: legend and title fontsize.

        Returns: |matplotlib-Figure|
        """
        # Build plot grid with (CBM, VBM) on each col. k-points along rows
        num_plots, ncols, nrows = self.nkcalc * 2, 2, self.nkcalc
github abinit / abipy / abipy / eph / sigeph.py View on Github external
    @add_fig_kwargs
    def plot_qpgaps_convergence(self, qp_kpoints="all", itemp=0, sortby=None, hue=None,
                                plot_qpmks=True, fontsize=8, **kwargs):
        """
        Plot the convergence of the direct QP gaps at given temperature
        for all the k-points and spins treated by the robot.

        Args:
            qp_kpoints: List of k-points in self-energy. Accept integers (list or scalars), list of vectors,
                or "all" to plot all k-points.
            itemp: Temperature index.
            sortby: Define the convergence parameter, sort files and produce plot labels.
                Can be None, string or function. If None, no sorting is performed.
                If string and not empty it's assumed that the abifile has an attribute
                with the same name and `getattr` is invoked.
                If callable, the output of sortby(abifile) is used.
            hue: Variable that define subsets of the data, which will be drawn on separate lines.
github abinit / abipy / abipy / electrons / ebands.py View on Github external
    @add_fig_kwargs
    def plot_with_edos(self, edos, klabels=None, axlist=None, e0="fermie", ylims=None, width_ratios=(2, 1), **kwargs):
        r"""
        Plot the band structure and the DOS.

        Args:
            edos: An instance of :class:`ElectronDos`.
            klabels: dictionary whose keys are tuple with the reduced coordinates of the k-points.
                The values are the labels. e.g. `klabels = {(0.0,0.0,0.0): "$\Gamma$", (0.5,0,0): "L"}`.
            axlist: The axes for the bandstructure plot and the DOS plot. If axlist is None, a new figure
                is created and the two axes are automatically generated.
            ylims: Set the data limits for the y-axis. Accept tuple e.g. `(left, right)`
                   or scalar e.g. `left`. If left (right) is None, default values are used
            e0: Option used to define the zero of energy in the band structure plot. Possible values:
                - `fermie`: shift all eigenvalues and the DOS to have zero energy at the Fermi energy.
                   Note that, by default, the Fermi energy is taken from the band structure object
                   i.e. the Fermi energy computed at the end of the SCF file that produced the density.
github abinit / abipy / abipy / eph / sigeph.py View on Github external
    @add_fig_kwargs
    def plot_vs_e0(self, itemp_list=None, with_fields="all", reim="real", function=lambda x: x,
                   exclude_fields=None, fermie=None, colormap="jet", ax_list=None, xlims=None, ylims=None,
                   exchange_xy=False, fontsize=12, **kwargs):
        """
        Plot the QP results as a function of the initial KS energy.

        Args:
            itemp_list: List of integers to select a particular temperature. None for all
            with_fields: The names of the qp attributes to plot as function of e0.
                Accepts: List of strings or string with tokens separated by blanks.
                See :class:`QPState` for the list of available fields.
            reim: Plot the real or imaginary part
            function: Apply a function to the results before plotting
            exclude_fields: Similar to `with_field` but excludes fields.
            fermie: Value of the Fermi level used in plot. None for absolute e0s.
            colormap: matplotlib color map.
github abinit / abipy / abipy / eph / gkq.py View on Github external
    @add_fig_kwargs
    def plot_diff_with_other(self, other, mode="phonon", ax_list=None, labels=None, fontsize=8, **kwargs):
        """
        Produce scatter plot and histogram to compare the gkq matrix elements stored in two files.

            other: other GkqFile instance.
            mode: "phonon" to plot eph matrix elements in the phonon representation,
                  "atom" for atomic representation.
            ax_list: List with 2 matplotlib axis. None if new ax_list should be created.
            labels: Labels associated to self and other
            fontsize: Label and title fontsize.

        Return: |matplotlib-Figure|
        """
        if self.qpoint != other.qpoint:
            raise ValueError("Found different q-points: %s and %s" % (self.qpoint, other.qpoint))
github abinit / abipy / abipy / eph / sigeph.py View on Github external
    @add_fig_kwargs
    def plot_qps_vs_e0(self, itemp_list=None, with_fields="all", reim="real",
                       function=lambda x: x, exclude_fields=None, e0="fermie",
                       colormap="jet", xlims=None, ylims=None, ax_list=None, fontsize=8, **kwargs):
        """
        Plot the QP results in the SIGEPH file as function of the initial KS energy.

        Args:
            itemp_list: List of integers to select a particular temperature. None means all
            with_fields: The names of the qp attributes to plot as function of e0.
                Accepts: List of strings or string with tokens separated by blanks.
                See :class:`QPState` for the list of available fields.
            reim: Plot the real or imaginary part
            function: Apply a function to the results before plotting
            exclude_fields: Similar to ``with_field`` but excludes fields.
            e0: Option used to define the zero of energy in the band structure plot. Possible values:
                - `fermie`: shift all eigenvalues to have zero energy at the Fermi energy (`self.fermie`).
github abinit / abipy / abipy / dfpt / phonons.py View on Github external
    @add_fig_kwargs
    def gridplot(self, with_dos=True, units="eV", **kwargs):
        """
        Plot multiple electron bandstructures and optionally DOSes on a grid.

        Args:
            units: Units for phonon plots. Possible values in ("eV", "Ha", "cm-1"). Case-insensitive.
            with_dos: True if DOS should be printed.

        Returns:
            matplotlib figure.
        """
        titles = list(self._bands_dict.keys())
        phb_objects = list(self._bands_dict.values())
        phdos_objects = None
        if self.phdoses_dict and with_dos:
            phdos_objects = list(self.phdoses_dict.values())
github abinit / abipy / abipy / wannier90 / abiwan.py View on Github external
    @add_fig_kwargs
    def plot(self, ax=None, fontsize=12, yscale="log", **kwargs):
        """
        Plot the matrix elements of the KS Hamiltonian in real space in the Wannier Gauge.

        Args:
            ax: |matplotlib-Axes| or None if a new figure should be created.
            fontsize: fontsize for legends and titles
            yscale: Define scale for y-axis. Passed to ax.set_yscale
            kwargs: options passed to ``ax.plot``.

        Return: |matplotlib-Figure|
        """
        # Sort R-points by length and build sortmap.
        irs = [ir for ir in enumerate(self.structure.lattice.norm(self.irvec))]
        items = sorted(irs, key=lambda t: t[1])
        sortmap = np.array([item[0] for item in items])
github abinit / abipy / abipy / dfpt / anaddbnc.py View on Github external
    @add_fig_kwargs
    def plot_elastic_properties(self, fontsize=10, **kwargs):
        """
        Args:
            fontsize: legend and label fontsize.

        Returns: |matplotlib-Figure|
        """
        df = self.get_elastic_dataframe(with_geo=False, abspath=False, with_params=False)
        from pandas.api.types import is_numeric_dtype
        keys = [k for k in df.keys() if is_numeric_dtype(df[k])]
        i = keys.index("fitted_to_structure")
        if i != -1:
            keys.pop(i)

        num_plots, ncols, nrows = len(keys), 1, 1
        if num_plots > 1:
github abinit / abipy / abipy / electrons / ebands.py View on Github external
    @add_fig_kwargs
    def plot(self, e0="fermie", spin=None, ax=None, xlims=None, **kwargs):
        """
        Plot electronic DOS

        Args:
            e0: Option used to define the zero of energy in the band structure plot. Possible values:
                - `fermie`: shift all eigenvalues to have zero energy at the Fermi energy (`self.fermie`).
                -  Number e.g e0=0.5: shift all eigenvalues to have zero energy at 0.5 eV
                -  None: Don't shift energies, equivalent to e0=0
            spin: Selects the spin component, None if total DOS is wanted.
            ax: matplotlib :class:`Axes` or None if a new figure should be created.
            xlims: Set the data limits for the x-axis. Accept tuple e.g. `(left, right)`
                   or scalar e.g. `left`. If left (right) is None, default values are used
            kwargs: options passed to ax.plot.

        Returns: