How to use the abipy.tools.plotting.set_axlims 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 / electrons / ebands.py View on Github external
numeb = len(edos_list)
        if numeb > 1:
            ncols = 2
            nrows = numeb // ncols + numeb % ncols

        # Build Grid
        fig, axes = plt.subplots(nrows=nrows, ncols=ncols, sharey=True, squeeze=False)
        axes = axes.ravel()
        # don't show the last ax if numeb is odd.
        if numeb % ncols != 0: axes[-1].axis("off")

        for i, (label, edos) in enumerate(self.edoses_dict.items()):
            ax = axes[i]
            edos.plot(ax=ax, e0=e0, show=False)
            ax.set_title(label)
            set_axlims(ax, xlims, "x")
            if i % ncols != 0:
                ax.set_ylabel("")

        return fig
github abinit / abipy / abipy / eph / sigeph.py View on Github external
if (ix == len(ax_list) - 1): ax.set_xlabel(xlabel)
            for itemp in itemps:
                ax.plot(xs, self._get_ys_itemp(what, itemp),
                        color=cmap(itemp / self.ntemp) if kw_color is None else kw_color,
                        label=tlabels[itemp] if (ix == 0 and kw_label is None) else kw_label,
                )
                if with_frohl:
                    # Add Frohlich contribution.
                    ax.plot(xs, self._get_ys_itemp(what, itemp, select_frohl=True),
                            color=cmap(itemp / self.ntemp) if kw_color is None else kw_color,
                            label="Frohlich",
                            #label=tlabels[itemp] if (ix == 0 and kw_label is None) else kw_label,
                    )

            if ix == 0: ax.legend(loc="best", shadow=True, fontsize=fontsize)
            set_axlims(ax, xlims, "x")

        if "title" not in kwargs:
            title = "K-point: %s, band: %d, spin: %d" % (repr(self.kpoint), self.band, self.spin)
            fig.suptitle(title, fontsize=fontsize)

        return fig
github abinit / abipy / abipy / electrons / optic.py View on Github external
Returns: |matplotlib-Figure|
        """
        comp2eps = self.reader.read_lineps(components, itemp=itemp)

        ax, fig, plt = get_ax_fig_plt(ax=ax)
        for comp, eps in comp2eps.items():
            values = LINEPS_WHAT2EFUNC[what](eps)
            # Note: I'm skipping the first point at w=0 because optic does not compute it!
            # The same trick is used in the other plots.
            ax.plot(self.wmesh[1:], values[1:],
                    label=self.get_linopt_latex_label(what, comp) if label is None else label)

        ax.grid(True)
        if with_xlabel: ax.set_xlabel('Photon Energy (eV)')
        set_axlims(ax, xlims, "x")
        ax.legend(loc="best", fontsize=fontsize, shadow=True)

        return fig
github abinit / abipy / abipy / electrons / fatbands.py View on Github external
tick.label1.set_fontsize(0)

                for spin in range(self.nsppol):
                    spin_sign = +1 if spin == 0 else -1
                    ax.plot(mesh, totdos_al[iatom, l, spin] * spin_sign, color="k",
                            label="Total" if (irow, l, spin) == (0, 0, 0) else None)
                    ax.plot(mesh, pwdos_al[iatom, l, spin] * spin_sign, color="r",
                            label="PW part" if (irow, l, spin) == (0, 0, 0) else None)
                    ax.plot(mesh, paw1dos_al[iatom, l, spin] * spin_sign, color="b",
                            label="AE-onsite" if (irow, l, spin) == (0, 0, 0) else None)
                    ax.plot(mesh, pawt1dos_al[iatom, l, spin] * spin_sign, color="g",
                            label="PS-onsite" if (irow, l, spin) == (0, 0, 0) else None)

        for ax in ax_mat[-1, :]:
            ax.set_xlabel('Energy (eV)')
            set_axlims(ax, xlims, "x")
github abinit / abipy / abipy / electrons / bse.py View on Github external
lines, legends = [], []
        for label, mdf_dict in self._mdfs.items():
            mdf = mdf_dict[mdf_type]
            # Plot the average value
            l = mdf.plot_ax(ax, qpoint, cplx_mode=cplx_mode, **kwargs)[0]
            lines.append(l)
            if can_use_basename:
                label = os.path.basename(label)
            else:
                # Use relative paths if label is a file.
                if os.path.isfile(label): label = os.path.relpath(label)

            legends.append(r"%s: %s, %s $\varepsilon$" % (cplx_mode, qtag, label))

        set_axlims(ax, xlims, "x")
        set_axlims(ax, ylims, "y")

        # Set legends.
        if with_legend:
            ax.legend(lines, legends, loc='best', fontsize=fontsize, shadow=True)

        return fig
github abinit / abipy / abipy / eph / sigeph.py View on Github external
"""
        #if not self.has_kpath: return None
        ax, fig, plt = get_ax_fig_plt(ax=ax)

        # Plot KS bands
        if self.ks_ebands_kpath is not None:
            ks_opts = dict(color="black", lw=2, label="KS")
            self.ks_ebands_kpath.plot_ax(ax, e0, **ks_opts)

        # Plot QP(T) bands with linewidths
        title = "T = %.1f K" % self.tmesh[itemp]
        qp_opts = dict(color="red", lw=2, label="QP", lw_opts=dict(fact=fact))
        self.qp_ebands_kpath_t[itemp].plot_ax(ax, e0, **qp_opts)
        self.qp_ebands_kpath_t[itemp].decorate_ax(ax, fontsize=fontsize, title=title)

        set_axlims(ax, ylims, "y")
        ax.legend(loc="best", fontsize=fontsize, shadow=True)

        return fig
github abinit / abipy / abipy / eph / a2f.py View on Github external
elif what == "lambda":
            lambda_w = self.get_moment(n=0, cumulative=True)
            xx, yy = self.mesh * wfactor, lambda_w
            if exchange_xy: xx, yy = yy, xx
            ax.plot(xx, yy, label=label, **style)

        else:
            raise ValueError("Invalid value for what: `%s`" % str(what))

        xlabel = abu.wlabel_from_units(units)
        if exchange_xy: xlabel, ylabel = ylabel, xlabel

        ax.set_xlabel(xlabel)
        ax.set_ylabel(ylabel)
        ax.grid(True)
        set_axlims(ax, xlims, "x")
        set_axlims(ax, ylims, "y")
        if label: ax.legend(loc="best", shadow=True, fontsize=fontsize)

        return fig
github abinit / abipy / abipy / eph / a2f.py View on Github external
vmin, vmax = cqn.min(), cqn.max()

        sc = ax.scatter(np.tile(xvals, len(self.phbands.branches)),
                        wvals.T, # [q, nu] --> [nu, q]
                        s=sqn.T,
                        c=cqn.T,
                        vmin=vmin, vmax=vmax,
                        cmap=cmap,
                        marker="o",
                        alpha=alpha,
                        #label=term if ib == 0 else None
        )

        # Make a color bar
        #plt.colorbar(sc, ax=ax, orientation="horizontal", pad=0.2)
        set_axlims(ax, ylims, "y")

        return fig
github abinit / abipy / abipy / electrons / ebands.py View on Github external
-  None: Don't shift energies, equivalent to e0=0

        Returns:
            `matplotlib` figure
        """
        # Select the band range.
        if band_range is None:
            band_range = range(self.mband)
        else:
            band_range = range(band_range[0], band_range[1], 1)

        ax, fig, plt = get_ax_fig_plt(ax=ax)

        # Decorate the axis (e.g add ticks and labels).
        self.decorate_ax(ax, klabels=klabels)
        set_axlims(ax, ylims, "y")

        # Plot the band energies.
        for spin in self.spins:
            if spin == 0:
                opts = {"color": "black", "linewidth": 2.0}
            else:
                opts = {"color": "red", "linewidth": 2.0}

            for band in band_range:
                self.plot_ax(ax, e0, spin=spin, band=band, **opts)

        return fig